Skip to content
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

dev branch updates #7

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions .github/workflows/build_and_push.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Staging Build and Deploy
on:
push:
branches: ["master"]
branches: ["dev"]

jobs:
build-and-push:
Expand All @@ -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:
Expand All @@ -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 }}
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.env
/.idea/.gitignore
/playground.py
.DS_Store
/dist
/qdrant_storage
*__pycache__*
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
22 changes: 12 additions & 10 deletions src/dria_searching_agent/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,18 +28,22 @@ 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

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

Expand All @@ -59,4 +62,3 @@ def BROWSERLESS_URL():
def VISION_TOOL_MODEL():
return config.vision_tool_model


7 changes: 4 additions & 3 deletions src/dria_searching_agent/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion src/dria_searching_agent/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Loading