Spaces:
Sleeping
Sleeping
Download src/study_chatbot/agent.py from hassan-ak/study-chatbot: direct link, hf CLI and curl.
- Browser
- Download file 795 Bytes
-
https://huggingface.co/spaces/hassan-ak/study-chatbot/resolve/main/src/study_chatbot/agent.py
- Command line
-
hf download hf://spaces/hassan-ak/study-chatbot/src/study_chatbot/agent.py
-
curl -L -o agent.py https://huggingface.co/spaces/hassan-ak/study-chatbot/resolve/main/src/study_chatbot/agent.py
795 Bytes
| from typing import Any | |
| import chainlit as cl | |
| from agents import ( | |
| Agent, | |
| AsyncOpenAI, | |
| OpenAIChatCompletionsModel, | |
| set_tracing_disabled, | |
| ) | |
| from config import Config | |
| from study_chatbot.instructions import STUDY_AGENT_INSTRUCTIONS | |
| def create_study_agent() -> Agent[Any]: | |
| """ | |
| Create and return a configured study Agent. | |
| """ | |
| config = Config() | |
| external_client = AsyncOpenAI( | |
| api_key=config.gemini_api_key, | |
| base_url=config.gemini_api_url, | |
| ) | |
| set_tracing_disabled(True) | |
| model = OpenAIChatCompletionsModel( | |
| model=config.gemini_api_model, openai_client=external_client | |
| ) | |
| study_agent = Agent( | |
| name="Study Agent", | |
| instructions=STUDY_AGENT_INSTRUCTIONS, | |
| model=model, | |
| ) | |
| return study_agent | |