Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

canopy server documentation #136

Merged
merged 35 commits into from
Nov 6, 2023
Merged

canopy server documentation #136

merged 35 commits into from
Nov 6, 2023

Conversation

miararoy
Copy link
Contributor

@miararoy miararoy commented Nov 2, 2023

Problem

FastAPI server needs to be documented

Solution

  • document the api methods
  • add response code documentation
  • document the API models
  • add fastapi app description
  • add CLI command canopy api-docs

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)
  • None of the above: (explain here)

Test Plan

Documentation linting and regression

Copy link
Contributor

@igiloh-pinecone igiloh-pinecone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There some things that need to be changed, namely:

  • The mechanism for generating docs (won't work in a PyPI package).
  • The new ContextContentResponse type
  • Incorrect documentation of some of the API parameters which are in fact not supported

src/canopy/models/data_models.py Outdated Show resolved Hide resolved
src/canopy/models/data_models.py Outdated Show resolved Hide resolved
src/canopy/models/data_models.py Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file definitely doesn't belong in the canopy_cli directory (package).

Usually, I would put this file somewhere under the repo's root (not inside src) and use it only in CI. But I get it that you want users to be able to build the documentation locally.
In that case - I'm not even sure this file will be included in the .whl without explicitly being included in the pyproject.toml.
Please check what is the best practice for allowing user's to get documentation locally.

"""
)
)
def docs():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again - I'm not sure that's a conventional practice...

Can't you just do something like:

check_service_health()
webbrowser.open('http://localhost:8000/rdocs')

It's so much simpler and more elegant...

src/canopy_server/app.py Outdated Show resolved Hide resolved
src/canopy_server/app.py Outdated Show resolved Hide resolved
src/canopy_server/app.py Outdated Show resolved Hide resolved
src/canopy_server/app.py Show resolved Hide resolved
src/canopy_server/app.py Show resolved Hide resolved
Copy link
Collaborator

@nc2112 nc2112 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few small changes

src/canopy/models/data_models.py Outdated Show resolved Hide resolved
## Prerequisites

### Pinecone API key
To get Pinecone free trial API key and environment register or log into your Pinecone account in the console (https://app.pinecone.io/). You can access your API key from the "API Keys" section in the sidebar of your dashboard, and find the environment name next to it.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should say 'free' rather than 'free trial' for Pinecone. Trial implies it ends, which our free tier does not

Copy link
Contributor

@byronnlandry byronnlandry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made various suggestions for usage, correctness, and concision.

src/canopy/models/data_models.py Outdated Show resolved Hide resolved
src/canopy/models/data_models.py Outdated Show resolved Hide resolved
)
metadata: Metadata = Field(
default_factory=dict,
description="The document metadata, to learn more about metadata, see https://docs.pinecone.io/docs/manage-data", # noqa: E501
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description="The document metadata, to learn more about metadata, see https://docs.pinecone.io/docs/manage-data", # noqa: E501
description="The document metadata. To learn more about metadata, see https://docs.pinecone.io/docs/manage-data", # noqa: E501

@@ -69,12 +88,12 @@ class Role(Enum):


class MessageBase(BaseModel):
role: Role
content: str
role: Role = Field(description="The role of the messages author.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
role: Role = Field(description="The role of the messages author.")
role: Role = Field(description="The role of the message author.")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
role: Role = Field(description="The role of the messages author.")
role: Role = Field(description="The role of the message's author.")

src/canopy_server/__init__.py Outdated Show resolved Hide resolved
src/canopy_server/app.py Outdated Show resolved Hide resolved
src/canopy_server/app.py Outdated Show resolved Hide resolved
src/canopy_server/app.py Outdated Show resolved Hide resolved
src/canopy_server/app.py Show resolved Hide resolved
src/canopy_server/app.py Show resolved Hide resolved
miararoy and others added 10 commits November 2, 2023 22:23
Instead of using process._parent_id which is not garuranteed, use `os.getppid()`
This is the official method by the mp module, which should work across all OSes (hopefully..)
It shouldn't theotically happen, but who knows...
This was a horrible name that doesn't represent the true meaning of this class
Per Nathan and Byron's feedback
This way they are only generated if the user want to generate them locally
Copy link
Contributor

@igiloh-pinecone igiloh-pinecone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed all issues. Ready for merge

This way, running 'canopy --help' prints the errors in the order matching the quick start
This conforms with the naming we use in the documentation
@igiloh-pinecone igiloh-pinecone added this pull request to the merge queue Nov 5, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 5, 2023
@igiloh-pinecone igiloh-pinecone added this pull request to the merge queue Nov 5, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 5, 2023
igiloh-pinecone and others added 6 commits November 5, 2023 15:33
In order to support our current StuffingContextBuilder, I added a new StuffingConxtextContent which inherits from ContextContent and implement to_text() correctly.
The app's `/query` path returns a `str`, which is the only guaranteed format of Context. It can be any strucured on unstrucutured data - depending on the ContextBuilder
- Made StuffingContextContent always a List
- Slightly improved readability of `StuffingContextBuilder`
I changed the tests to use explicit json.loads()
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

igiloh-pinecone and others added 4 commits November 6, 2023 13:43
KISS solution - simply return a different model than the actual internal `Context`
Context must contain a ContextContent that implements to_text()
@igiloh-pinecone igiloh-pinecone added this pull request to the merge queue Nov 6, 2023
Merged via the queue into dev with commit 2be988e Nov 6, 2023
10 checks passed
@igiloh-pinecone igiloh-pinecone deleted the server-docstrings branch November 6, 2023 15:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants