Processing documents via the API? #100
-
Hi, I like the idea of the API and I have played around with the examples for the regular script although there's not much documentation in terms of the API. This is my version: '1.0' # Version of this configuration file
tasks:
- name: "summarize"
system_prompt: "You are an expert ai assistant specialized in summarization." # System prompt for this task
vector_store_params:
vector_store_type: "LanceDBVectorStore"
uri: "tmp/lancedb"
collection_name: "summarize"
llm_params:
model: "gpt-3.5-turbo"
service_context_params:
chunk_size: 1024
query_engine_params:
similarity_top_k: 5
enable_cost_calculator: true
- name: "qa"
system_prompt: "You are a friendly ai assistant specialized in question answering." # System prompt for this task
vector_store_params:
vector_store_type: "LanceDBVectorStore"
uri: "tmp/lancedb"
collection_name: "qa"
llm_params:
model: "gpt-4"
service_context_params:
chunk_size: 1024
query_engine_params:
similarity_top_k: 3
enable_cost_calculator: false And this is my api.py: import uvicorn
from autollm import AutoFastAPI
app = AutoFastAPI.from_config("config.yaml")
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000) How can I load a GitHub Readme.md from a URL via this API? From the generated OpenAPI documentation itself, I can see there seem to be 3 available query params:
Is it possible to somehow pass the Readme URL somehow? When I try to pass it within the user_query itself, it gives an error like: Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @jontstaz, First off, thank you for exploring our API and for your valuable feedback. We’re thrilled to hear about your interest and usage! To summarize content from a GitHub Here’s how you can use it: from autollm import read_github_repo_as_documents, AutoFastAPI
# Specify the GitHub repository and the relative path within the repository
git_repo_url = "https://github.com/your-username/your-repo.git"
relative_folder_path = "path-to-folder" # e.g., "docs" if the README is in a 'docs' folder, "." if its in the root
required_exts = [".md"] # Specify the extensions of the documents to be read
# Read the documents from the GitHub repository
documents = read_github_repo_as_documents(
git_repo_url=git_repo_url,
relative_folder_path=relative_folder_path,
required_exts=required_exts
)
# Provide these documents when creating the FastAPI app
app = AutoFastAPI.from_config("config.yaml", documents=documents) Once you have the documents loaded, you can start your FastAPI server as you've outlined in your In the future, we plan to support direct document uploading through the API itself, which will be facilitated through an easy-to-use interface. This enhancement will allow for even smoother workflows and we’re excited about the possibilities it will open up. If you face any issues or have further questions, feel free to reach out. Best wishes, |
Beta Was this translation helpful? Give feedback.
Hi @jontstaz,
First off, thank you for exploring our API and for your valuable feedback. We’re thrilled to hear about your interest and usage!
To summarize content from a GitHub
README.md
, you'll need to fetch the document content beforehand and then provide it to the API. We have a utility function,read_github_repo_as_documents
, which you can use to read documents from a GitHub repository.Here’s how you can use it: