-
Notifications
You must be signed in to change notification settings - Fork 0
feat(config): enhance configs with descriptions for fields #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,22 +46,48 @@ def validate_template(template: str): | |
|
|
||
|
|
||
| class QDrantConfig(BaseSettings): | ||
| host: str = Field("test", validation_alias="QDRANT_HOST") | ||
| port: int = Field(6333, gt=0, validation_alias="QDRANT_PORT") | ||
| collection: str = Field("news", validation_alias="QDRANT_COLLECTION") | ||
| host: str = Field( | ||
| "test", | ||
| validation_alias="QDRANT_HOST", | ||
| description="Qdrant vector database host address. Default is 'test'.", | ||
| ) | ||
| port: int = Field( | ||
| 6333, | ||
| gt=0, | ||
| validation_alias="QDRANT_PORT", | ||
| description="Qdrant vector database port. Default is 6333.", | ||
| ) | ||
| collection: str = Field( | ||
| "news", | ||
| validation_alias="QDRANT_COLLECTION", | ||
| description="Qdrant vector database collection name. Default is 'news'.", | ||
| ) | ||
|
|
||
|
|
||
| class RetrieveConfig(BaseModel): | ||
| vector_database: QDrantConfig = QDrantConfig() # type: ignore | ||
| embedding_model: str = Field( | ||
| DEFAULT_EMBEDDING_MODEL, | ||
| description="Name of embedding model." | ||
| "All available models can be found [here](https://huggingface.co/models?library=sentence-transformers&language=zh).", | ||
| description=( | ||
| "Embedding model name. " | ||
| "See https://huggingface.co/models?library=sentence-transformers&language=zh for available models. " | ||
| f"Default is '{DEFAULT_EMBEDDING_MODEL}'." | ||
| ), | ||
| ) | ||
| prompt_template: Annotated[ | ||
| str, AfterValidator(contains_placeholder("keywords")) | ||
| ] = DEFAULT_QUERY_PROMPT_TEMPLATE | ||
| similarity_top_k: int = Field(DEFAULT_SIMILARITY_TOP_K, gt=1) | ||
| ] = Field( | ||
| DEFAULT_QUERY_PROMPT_TEMPLATE, | ||
| description="Prompt template for retrieval. Must contain the {keywords} placeholder.", | ||
|
Comment on lines
+79
to
+81
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ) | ||
| similarity_top_k: int = Field( | ||
| DEFAULT_SIMILARITY_TOP_K, | ||
| gt=1, | ||
| description=( | ||
| "Number of top similar results to return during retrieval. " | ||
| f"Default is {DEFAULT_SIMILARITY_TOP_K}." | ||
| ), | ||
|
Comment on lines
+86
to
+89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ) | ||
|
|
||
|
|
||
| def is_available_model(model_name: str): | ||
|
|
@@ -73,25 +99,41 @@ def is_available_model(model_name: str): | |
|
|
||
|
|
||
| class ChatGptConfig(BaseSettings): | ||
| api_key: str = Field(validation_alias="OPENAI_API_KEY") | ||
| api_key: str = Field( | ||
| validation_alias="OPENAI_API_KEY", description="OpenAI API key." | ||
| ) | ||
| model: Annotated[ | ||
| str, | ||
| Field(DEFAULT_OPENAI_MODEL), | ||
| AfterValidator(is_available_model), | ||
| ] | ||
| ] = Field( | ||
| DEFAULT_OPENAI_MODEL, | ||
| description=f"OpenAI LLM model name. Default is '{DEFAULT_OPENAI_MODEL}'.", | ||
| ) | ||
|
|
||
|
|
||
| class SummarizeConfig(BaseModel): | ||
| llm: ChatGptConfig = ChatGptConfig() # type: ignore | ||
| system_template: str = DEFAULT_SYSTEM_TEMPLATE | ||
| llm: ChatGptConfig = Field( | ||
| default_factory=ChatGptConfig, # # type: ignore | ||
david20571015 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| description="Configuration for the LLM used for summarization.", | ||
|
||
| ) | ||
| system_template: str = Field( | ||
| DEFAULT_SYSTEM_TEMPLATE, | ||
| description="System prompt template for the LLM, used to set the role and rules.", | ||
| ) | ||
| user_template: Annotated[ | ||
| str, AfterValidator(contains_placeholder("context_str", "query_str")) | ||
| ] = DEFAULT_USER_TEMPLATE | ||
| ] = Field( | ||
| DEFAULT_USER_TEMPLATE, | ||
| description="User prompt template for the LLM. Must contain {context_str} and {query_str} placeholders.", | ||
|
Comment on lines
+125
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ) | ||
| query_str: str = Field( | ||
| DEFAULT_QUERY_STR, | ||
| description="The content of `{query_str}` placeholder in the user template.", | ||
| description="Content for the {query_str} placeholder in user_template.", | ||
| ) | ||
| content_format: ContentFormat = Field( | ||
| ContentFormat.PLAIN, | ||
| description=f"Format of the summary content. Options: {', '.join(e.value for e in ContentFormat)}.", | ||
| ) | ||
| content_format: ContentFormat = ContentFormat.PLAIN | ||
|
|
||
|
|
||
| class RagConfig(BaseModel): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a default value to the description for better clarity and user experience. Also, the link is in Chinese; consider providing an English alternative or mentioning that the linked page is in Chinese.