-
-
Notifications
You must be signed in to change notification settings - Fork 269
Develop #163
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
base: main
Are you sure you want to change the base?
Develop #163
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # PR #1 Ali 11/18/2025 | ||
| ## Features | ||
| - added groq provider | ||
| ## Added Files | ||
| - CHANGELOG.md | ||
| ## Fixes | ||
| changed the submit button from ctrl+j to enter | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -490,15 +490,15 @@ def get_multiline_input(prompt_text: str = "Ask a question") -> str: | |||||||||||||||||||||||||||||||||||||||||||||
| """Get multiline input from user with Ctrl+J to submit.""" | ||||||||||||||||||||||||||||||||||||||||||||||
| bindings = KeyBindings() | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @bindings.add("c-j") | ||||||||||||||||||||||||||||||||||||||||||||||
| @bindings.add("enter") | ||||||||||||||||||||||||||||||||||||||||||||||
| def submit(event: Any) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||
| """Submit the current input.""" | ||||||||||||||||||||||||||||||||||||||||||||||
| event.app.exit(result=event.app.current_buffer.text) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @bindings.add("enter") | ||||||||||||||||||||||||||||||||||||||||||||||
| def new_line(event: Any) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||
| """Insert a new line instead of submitting.""" | ||||||||||||||||||||||||||||||||||||||||||||||
| event.current_buffer.insert_text("\n") | ||||||||||||||||||||||||||||||||||||||||||||||
| # @bindings.add("enter") | ||||||||||||||||||||||||||||||||||||||||||||||
| # def new_line(event: Any) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||
| # """Insert a new line instead of submitting.""" | ||||||||||||||||||||||||||||||||||||||||||||||
| # event.current_buffer.insert_text("\n") | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+493
to
+501
Contributor
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. By changing the submit key to I suggest swapping the key bindings, so that Additionally, the function's docstring on line 490 and the user prompt on line 514 are now outdated and should be updated to reflect these new key bindings. For example:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @bindings.add("c-c") | ||||||||||||||||||||||||||||||||||||||||||||||
| def keyboard_interrupt(event: Any) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,8 @@ | |||||
| from pydantic_ai.providers.google_gla import GoogleGLAProvider | ||||||
| from pydantic_ai.providers.google_vertex import GoogleVertexProvider, VertexAiRegion | ||||||
| from pydantic_ai.providers.openai import OpenAIProvider as PydanticOpenAIProvider | ||||||
| from pydantic_ai.models.groq import GroqModel | ||||||
| from pydantic_ai.providers.groq import GroqProvider as PydanticGroqProvider | ||||||
|
|
||||||
|
|
||||||
| class ModelProvider(ABC): | ||||||
|
|
@@ -125,6 +127,26 @@ def create_model(self, model_id: str, **kwargs: Any) -> OpenAIResponsesModel: | |||||
| return OpenAIResponsesModel(model_id, provider=provider, **kwargs) | ||||||
|
|
||||||
|
|
||||||
| class GroqProvider(ModelProvider): | ||||||
| """Groq provider – uses Groq’s ultra‑fast inference API.""" | ||||||
| def __init__(self, api_key: str | None = None, **kwargs: Any) -> None: | ||||||
| super().__init__(**kwargs) | ||||||
| self.api_key = api_key | ||||||
|
|
||||||
| @property | ||||||
| def provider_name(self) -> str: | ||||||
| return "groq" | ||||||
|
|
||||||
| def validate_config(self) -> None: | ||||||
| if not self.api_key: | ||||||
| raise ValueError("Groq provider requires api_key.") | ||||||
|
Contributor
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. This error message is a bit generic. For a better user experience, it would be helpful to guide the user on how to provide the API key, similar to how other providers in this file do (e.g., by suggesting which environment variable to set).
Suggested change
|
||||||
|
|
||||||
| def create_model(self, model_id: str, **kwargs: Any) -> GroqModel: | ||||||
| self.validate_config() | ||||||
| provider = PydanticGroqProvider(api_key=self.api_key) | ||||||
| return GroqModel(model_id, provider=provider, **kwargs) | ||||||
|
|
||||||
|
|
||||||
| class OllamaProvider(ModelProvider): | ||||||
| """Ollama local provider.""" | ||||||
|
|
||||||
|
|
@@ -163,6 +185,7 @@ def create_model(self, model_id: str, **kwargs: Any) -> OpenAIModel: | |||||
| PROVIDER_REGISTRY: dict[str, type[ModelProvider]] = { | ||||||
| "google": GoogleProvider, | ||||||
| "openai": OpenAIProvider, | ||||||
| "groq": GroqProvider, | ||||||
| "ollama": OllamaProvider, | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -198,4 +221,4 @@ def check_ollama_running(endpoint: str = "http://localhost:11434") -> bool: | |||||
| response = client.get(health_url) | ||||||
| return bool(response.status_code == 200) | ||||||
| except (httpx.RequestError, httpx.TimeoutException): | ||||||
| return False | ||||||
| return False | ||||||
|
Contributor
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. |
||||||
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.
There's a trailing space after
Fixes. For consistency with the other headers in this file, it should be removed.