diff --git a/.github/workflows/build_and_push.yml b/.github/workflows/build_and_push.yml index c293a03..e064564 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,14 +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/amd64 --builder=ibuilder -t $IMAGE_NAME:$IMAGE_TAG-amd64 --load . - docker push $IMAGE_NAME:$IMAGE_TAG-amd64 - docker rmi $IMAGE_NAME:$IMAGE_TAG-amd64 + 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 }} diff --git a/.gitignore b/.gitignore index 702d4c2..5eebb57 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ .env /.idea/.gitignore /playground.py +.DS_Store +/dist +/qdrant_storage +*__pycache__* \ No newline at end of file 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 156ca91..7b56f14 100644 --- a/src/dria_searching_agent/config/config.py +++ b/src/dria_searching_agent/config/config.py @@ -5,22 +5,21 @@ 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') self.openai_api_key = os.getenv('OPENAI_API_KEY') 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 @@ -29,8 +28,15 @@ 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(): + try: + int_val = int(config.agent_max_iter) + return int_val + except ValueError: + return 10 def ANTHROPIC_KEY(): return config.anthropic_key @@ -38,9 +44,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 +62,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..cc9811c 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=[ @@ -163,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(api_key=config.AGENT_MODEL(), model=config.OPENAI_MODEL_NAME()) + 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(): 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')