crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[Not a issue] Add local tools for CrewAI example instragram

Open Guerdal opened this issue 1 year ago • 0 comments

CrewAI is a fantastic project. However, I tried to work on the instagram_post example (https://github.com/joaomdmoura/crewAI-examples/tree/main/instagram_post) to make it run with minimal cloud-dependent tools.

Here are some ideas, tools and code modifications of the example that allow it to work locally.

The base example works with ChatGPT, so I made a simple first modification (other examples work this way) to work with Ollama and the Openchat2.5 model.

In the agents.py file:

line 13 : self.llm = Ollama(base_url='http://IP_of_Ollama_Server:11434',model='openchat')

Then the example uses two online tools: browserless.io and serper.dev.

To replace them, I installed the Docker version of browserless.io (https://www.browserless.io/docs/docker-quickstart) and openserp (https://github.com/karust/openserp)

Browserless will be accessible via the URL http://IP_server:9222 and Openserp will be accessible via the URL http://IP_server:7000

To make it work, I modified the following files:

browsertools.py

line 17 : url = f"http://IP_Server:9222/content"

line 32 : llm=Ollama(base_url='http://IP_of_Ollama_Server:11434',model='openchat'),

search_tools.py

starting from line 23:

def search(query, n_results=5): url = "http://IP_server:7000/google/search?limit=20&lang=FR&text="+query

response = requests.request("GET", url)
results = response.json()
stirng = []
for result in results[:n_results]:
  try:
    stirng.append('\n'.join([
        f"Title: {result['title']}", f"Link: {result['url']}",
        f"Snippet: {result['description']}", "\n-----------------"
    ]))
  except KeyError:
    next

Openserp works with GET, so I modified the search function that used POST.

If some people want to exchange or have ideas for improvement or tools that can run locally (ideally in Docker), they don't hesitate to contribute to this great tool which is CrewAI.

Guerdal avatar Feb 05 '24 17:02 Guerdal