From 32bcad06c007adc3662ddadf7ebed3c8c4ef1d12 Mon Sep 17 00:00:00 2001 From: selimseker Date: Thu, 6 Jun 2024 16:52:58 +0300 Subject: [PATCH 1/9] openai config setup fixed --- src/dria_searching_agent/config/config.py | 6 ------ src/dria_searching_agent/main.py | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/dria_searching_agent/config/config.py b/src/dria_searching_agent/config/config.py index 156ca91..aa2b68e 100644 --- a/src/dria_searching_agent/config/config.py +++ b/src/dria_searching_agent/config/config.py @@ -13,14 +13,12 @@ def __init__(self): self.serper_api_key = os.getenv('SERPER_API_KEY') self.browserless_token = os.getenv('BROWSERLESS_TOKEN') - self.openai_model_name = os.getenv('OPENAI_MODEL_NAME', "gpt-4") self.vision_tool_model = os.getenv('VISION_TOOL_MODEL', "CLAUDE_SONNET") self.ollama_url = os.getenv('OLLAMA_URL') self.qdrant_url = os.getenv('QDRANT_URL') self.browserless_url = os.getenv('BROWSERLESS_URL') - config = Config() def load_config(): global config @@ -38,9 +36,6 @@ def ANTHROPIC_KEY(): def OPENAI_API_KEY(): return config.openai_api_key -def OPENAI_MODEL_NAME(): - return config.openai_model_name - def OLLAMA_URL(): return config.ollama_url @@ -59,4 +54,3 @@ def BROWSERLESS_URL(): def VISION_TOOL_MODEL(): return config.vision_tool_model - diff --git a/src/dria_searching_agent/main.py b/src/dria_searching_agent/main.py index 62c8b52..397ff64 100644 --- a/src/dria_searching_agent/main.py +++ b/src/dria_searching_agent/main.py @@ -165,7 +165,7 @@ def __get_model(self): if config.AGENT_MODEL_PROVIDER().lower() == "anthropic": return ChatAnthropic(model=config.AGENT_MODEL(), api_key=config.ANTHROPIC_KEY()) elif config.AGENT_MODEL_PROVIDER().lower() == "openai": - return ChatOpenAI(api_key=config.AGENT_MODEL(), model=config.OPENAI_MODEL_NAME()) + return ChatOpenAI(model=config.AGENT_MODEL(), api_key=config.OPENAI_API_KEY()) elif config.AGENT_MODEL_PROVIDER().lower() == "ollama": return ollama.Ollama(model=config.AGENT_MODEL(), base_url=config.OLLAMA_URL()) From 33403305537446e2a2d98334681e919a8bc7b5e8 Mon Sep 17 00:00:00 2001 From: selimseker Date: Thu, 6 Jun 2024 16:56:26 +0300 Subject: [PATCH 2/9] update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 702d4c2..83c7997 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .env /.idea/.gitignore /playground.py +.DS_Store +/dist \ No newline at end of file From 5e5ea097091af732efe9894088a879e2e7104296 Mon Sep 17 00:00:00 2001 From: selimseker Date: Thu, 6 Jun 2024 16:58:04 +0300 Subject: [PATCH 3/9] trigger github action on dev branch --- .github/workflows/build_and_push.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_and_push.yml b/.github/workflows/build_and_push.yml index c293a03..2f77f1a 100644 --- a/.github/workflows/build_and_push.yml +++ b/.github/workflows/build_and_push.yml @@ -1,7 +1,7 @@ name: Staging Build and Deploy on: push: - branches: ["master"] + branches: ["dev"] jobs: build-and-push: @@ -28,6 +28,17 @@ jobs: id: iname run: echo "iname=firstbatch/${{ github.event.repository.name }}" >> $GITHUB_OUTPUT + - name: Remove unnecessary files # https://github.com/actions/runner-images/issues/2840#issuecomment-1284059930 + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 with: @@ -39,15 +50,10 @@ jobs: IMAGE_TAG: ${{ steps.itag.outputs.itag }} run: | docker buildx create --use --name ibuilder --driver docker-container - docker buildx build --platform linux/arm64 --builder=ibuilder -t $IMAGE_NAME:$IMAGE_TAG-arm64 --load . docker push $IMAGE_NAME:$IMAGE_TAG-arm64 docker rmi $IMAGE_NAME:$IMAGE_TAG-arm64 - docker buildx build --platform linux/amd64 --builder=ibuilder -t $IMAGE_NAME:$IMAGE_TAG-amd64 --load . - docker push $IMAGE_NAME:$IMAGE_TAG-amd64 - docker rmi $IMAGE_NAME:$IMAGE_TAG-amd64 - outputs: itag: ${{ steps.itag.outputs.itag }} iname: ${{ steps.iname.outputs.iname }} \ No newline at end of file From 289e777b2f21565f8314861f40924c1b7158eaf0 Mon Sep 17 00:00:00 2001 From: selimseker Date: Thu, 6 Jun 2024 18:11:13 +0300 Subject: [PATCH 4/9] remove ratelimit --- src/dria_searching_agent/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dria_searching_agent/server.py b/src/dria_searching_agent/server.py index af308c2..4f698ba 100644 --- a/src/dria_searching_agent/server.py +++ b/src/dria_searching_agent/server.py @@ -30,7 +30,7 @@ def decorated_function(*args, **kwargs): @app.route('/search', methods=['POST']) @validate_query -@limiter.limit("3 per minute") +# @limiter.limit("3 per minute") def search(): data = request.get_json() query = data.get('query') From 6923e31b72b89f07ccda7e39c9c408c428100677 Mon Sep 17 00:00:00 2001 From: selimseker Date: Thu, 6 Jun 2024 19:45:22 +0300 Subject: [PATCH 5/9] update .gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 83c7997..5eebb57 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ /.idea/.gitignore /playground.py .DS_Store -/dist \ No newline at end of file +/dist +/qdrant_storage +*__pycache__* \ No newline at end of file From 4385bfb3a5d780177e1e096bd022ea779d69e7ea Mon Sep 17 00:00:00 2001 From: selimseker Date: Thu, 6 Jun 2024 19:46:15 +0300 Subject: [PATCH 6/9] get agent max_iter config from env-var --- src/dria_searching_agent/config/config.py | 4 ++++ src/dria_searching_agent/main.py | 1 + 2 files changed, 5 insertions(+) diff --git a/src/dria_searching_agent/config/config.py b/src/dria_searching_agent/config/config.py index aa2b68e..9fedc55 100644 --- a/src/dria_searching_agent/config/config.py +++ b/src/dria_searching_agent/config/config.py @@ -7,6 +7,7 @@ def __init__(self): self.agent_model_provider = os.getenv('AGENT_MODEL_PROVIDER') self.agent_model = os.getenv('AGENT_MODEL') + self.agent_max_iter = os.getenv('AGENT_MAX_ITER', 10) self.anthropic_key = os.getenv('ANTHROPIC_KEY') self.openai_api_key = os.getenv('OPENAI_API_KEY') @@ -30,6 +31,9 @@ def AGENT_MODEL_PROVIDER(): def AGENT_MODEL(): return config.agent_model +def AGENT_MAX_ITER(): + return config.agent_max_iter + def ANTHROPIC_KEY(): return config.anthropic_key diff --git a/src/dria_searching_agent/main.py b/src/dria_searching_agent/main.py index 397ff64..c99f36c 100644 --- a/src/dria_searching_agent/main.py +++ b/src/dria_searching_agent/main.py @@ -120,6 +120,7 @@ def __create_agents(self): for k,v in self.agents_config.items(): agent = Agent( **v, + max_iter=config.AGENT_MAX_ITER(), # TODO: maybe we can get this from agents.json verbose=True, llm = self.__get_model(), tools=[ From 3ef75ad28449bb30fab27d9673daf5190e4d1440 Mon Sep 17 00:00:00 2001 From: selimseker Date: Fri, 7 Jun 2024 15:58:47 +0300 Subject: [PATCH 7/9] change image tag --- .github/workflows/build_and_push.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_push.yml b/.github/workflows/build_and_push.yml index 2f77f1a..e064564 100644 --- a/.github/workflows/build_and_push.yml +++ b/.github/workflows/build_and_push.yml @@ -50,9 +50,9 @@ jobs: IMAGE_TAG: ${{ steps.itag.outputs.itag }} run: | docker buildx create --use --name ibuilder --driver docker-container - docker buildx build --platform linux/arm64 --builder=ibuilder -t $IMAGE_NAME:$IMAGE_TAG-arm64 --load . - docker push $IMAGE_NAME:$IMAGE_TAG-arm64 - docker rmi $IMAGE_NAME:$IMAGE_TAG-arm64 + docker buildx build --platform linux/arm64 --builder=ibuilder -t $IMAGE_NAME:$IMAGE_TAG --load . + docker push $IMAGE_NAME:$IMAGE_TAG + docker rmi $IMAGE_NAME:$IMAGE_TAG outputs: itag: ${{ steps.itag.outputs.itag }} From 47fe496fec9a56a866beb52e61b445ec8ac06924 Mon Sep 17 00:00:00 2001 From: selimseker Date: Tue, 11 Jun 2024 22:58:01 +0300 Subject: [PATCH 8/9] fix model-name env var --- docker-compose.yml | 6 +++--- src/dria_searching_agent/config/config.py | 8 ++++---- src/dria_searching_agent/main.py | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5f756e7..1a2a183 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -31,15 +31,15 @@ services: profiles: [ollama-docker] search-agent-server: - image: dria-searching-agent:server + image: firstbatch/dria-searching-agent:latest build: context: . dockerfile: Dockerfile ports: - 5000:5000 environment: - AGENT_MODEL_PROVIDER: Ollama - AGENT_MODEL: phi3:latest + AGENT_MODEL_PROVIDER: ${AGENT_MODEL_PROVIDER} + AGENT_MODEL_NAME: ${AGENT_MODEL_NAME} ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY} OPENAI_API_KEY: ${OPENAI_API_KEY} diff --git a/src/dria_searching_agent/config/config.py b/src/dria_searching_agent/config/config.py index 9fedc55..b7c41eb 100644 --- a/src/dria_searching_agent/config/config.py +++ b/src/dria_searching_agent/config/config.py @@ -5,8 +5,8 @@ class Config: def __init__(self): load_dotenv() # This loads environment variables from a .env file if it exists - self.agent_model_provider = os.getenv('AGENT_MODEL_PROVIDER') - self.agent_model = os.getenv('AGENT_MODEL') + self.agent_model_provider = os.getenv('AGENT_MODEL_PROVIDER', "ollama") + self.agent_model_name = os.getenv('AGENT_MODEL_NAME', "gpt-4o") self.agent_max_iter = os.getenv('AGENT_MAX_ITER', 10) self.anthropic_key = os.getenv('ANTHROPIC_KEY') @@ -28,8 +28,8 @@ def load_config(): def AGENT_MODEL_PROVIDER(): return config.agent_model_provider -def AGENT_MODEL(): - return config.agent_model +def AGENT_MODEL_NAME(): + return config.agent_model_name def AGENT_MAX_ITER(): return config.agent_max_iter diff --git a/src/dria_searching_agent/main.py b/src/dria_searching_agent/main.py index c99f36c..cc9811c 100644 --- a/src/dria_searching_agent/main.py +++ b/src/dria_searching_agent/main.py @@ -164,11 +164,11 @@ def __create_agents(self): def __get_model(self): if config.AGENT_MODEL_PROVIDER().lower() == "anthropic": - return ChatAnthropic(model=config.AGENT_MODEL(), api_key=config.ANTHROPIC_KEY()) + return ChatAnthropic(model=config.AGENT_MODEL_NAME(), api_key=config.ANTHROPIC_KEY()) elif config.AGENT_MODEL_PROVIDER().lower() == "openai": - return ChatOpenAI(model=config.AGENT_MODEL(), api_key=config.OPENAI_API_KEY()) + return ChatOpenAI(model=config.AGENT_MODEL_NAME(), api_key=config.OPENAI_API_KEY()) elif config.AGENT_MODEL_PROVIDER().lower() == "ollama": - return ollama.Ollama(model=config.AGENT_MODEL(), base_url=config.OLLAMA_URL()) + return ollama.Ollama(model=config.AGENT_MODEL_NAME(), base_url=config.OLLAMA_URL()) _research_crew_instance = None def GetResearchCrew(): From bace81ea38f43f5f0ed8b10cc44c139a34632a19 Mon Sep 17 00:00:00 2001 From: selimseker Date: Wed, 12 Jun 2024 10:10:09 +0300 Subject: [PATCH 9/9] parse string env to int --- src/dria_searching_agent/config/config.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dria_searching_agent/config/config.py b/src/dria_searching_agent/config/config.py index b7c41eb..7b56f14 100644 --- a/src/dria_searching_agent/config/config.py +++ b/src/dria_searching_agent/config/config.py @@ -32,7 +32,11 @@ def AGENT_MODEL_NAME(): return config.agent_model_name def AGENT_MAX_ITER(): - return config.agent_max_iter + try: + int_val = int(config.agent_max_iter) + return int_val + except ValueError: + return 10 def ANTHROPIC_KEY(): return config.anthropic_key