MervinPraison / PraisonAI

PraisonAI application combines AutoGen and CrewAI or similar frameworks into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human-agent collaboration.
https://docs.praison.ai
MIT License
1.24k stars 188 forks source link

ollama on windows not working #21

Open oldlastman opened 3 months ago

oldlastman commented 3 months ago

im trying to execute on windows with ollama an llama2 model

after some minutes of working i get this error:

python -m praisonai --init give me the latest news about openai
(windows does not recognize praison as a command  )

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\oldla\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\praisonai\__main__.py", line 10, in <module>
    main()
  File "C:\Users\oldla\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\praisonai\__main__.py", line 7, in main
    praison_ai.main()
  File "C:\Users\oldla\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\praisonai\cli.py", line 76, in main
    self.agent_file = generator.generate()
                      ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oldla\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\praisonai\auto.py", line 45, in generate
    response = self.client.chat.completions.create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oldla\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\instructor\patch.py", line 570, in new_create_sync
    response = retry_sync(
               ^^^^^^^^^^^
  File "C:\Users\oldla\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\instructor\patch.py", line 387, in retry_sync
    for attempt in max_retries:
  File "C:\Users\oldla\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\tenacity\__init__.py", line 347, in __iter__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oldla\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\tenacity\__init__.py", line 325, in iter
    raise retry_exc.reraise()
          ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oldla\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\tenacity\__init__.py", line 158, in reraise
    raise self.last_attempt.result()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1008.0_x64__qbz5n2kfra8p0\Lib\concurrent\futures\_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1008.0_x64__qbz5n2kfra8p0\Lib\concurrent\futures\_base.py", line 401, in __get_result
    raise self._exception
  File "C:\Users\oldla\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\instructor\patch.py", line 441, in retry_sync
    raise e
  File "C:\Users\oldla\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\instructor\patch.py", line 402, in retry_sync
    return process_response(
           ^^^^^^^^^^^^^^^^^
  File "C:\Users\oldla\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\instructor\patch.py", line 207, in process_response
    model = response_model.from_response(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oldla\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\instructor\function_calls.py", line 131, in from_response
    return cls.model_validate_json(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oldla\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pydantic\main.py", line 561, in model_validate_json
    return cls.__pydantic_validator__.validate_json(json_data, strict=strict, context=context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for TeamStructure
  Invalid JSON: EOF while parsing an object at line 75 column 0 [type=json_invalid, input_value='{\n"roles": {\n"narrativ...n\n\n\n\n\n\n\n\n\n\n\n', input_type=str]
    For further information visit https://errors.pydantic.dev/2.7/v/json_invalid

any clue how to solve?

zsb87 commented 1 month ago

@oldlastman Has your issue got resolved? I met with connection error when using ollama:


  warnings.warn(
Traceback (most recent call last):
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_transports\default.py", line 69, in map_httpcore_exceptions
    yield
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_transports\default.py", line 233, in handle_request
    resp = self._pool.handle_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpcore\_sync\connection_pool.py", line 167, in handle_request
    raise UnsupportedProtocol(
httpcore.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\openai\_base_client.py", line 918, in _request
    response = self._client.send(
               ^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_client.py", line 914, in send
    response = self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_client.py", line 942, in _send_handling_auth
    response = self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_client.py", line 979, in _send_handling_redirects
    response = self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_client.py", line 1015, in _send_single_request
    response = transport.handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_transports\default.py", line 232, in handle_request
    with map_httpcore_exceptions():
  File "C:\Program Files\Python312\Lib\contextlib.py", line 155, in __exit__
    self.gen.throw(value)
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_transports\default.py", line 86, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_transports\default.py", line 69, in map_httpcore_exceptions
    yield
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_transports\default.py", line 233, in handle_request
    resp = self._pool.handle_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpcore\_sync\connection_pool.py", line 167, in handle_request
    raise UnsupportedProtocol(
httpcore.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\openai\_base_client.py", line 918, in _request
    response = self._client.send(
               ^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_client.py", line 914, in send
    response = self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_client.py", line 942, in _send_handling_auth
    response = self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_client.py", line 979, in _send_handling_redirects
    response = self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_client.py", line 1015, in _send_single_request
    response = transport.handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_transports\default.py", line 232, in handle_request
    with map_httpcore_exceptions():
  File "C:\Program Files\Python312\Lib\contextlib.py", line 155, in __exit__
    self.gen.throw(value)
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_transports\default.py", line 86, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_transports\default.py", line 69, in map_httpcore_exceptions
    yield
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_transports\default.py", line 233, in handle_request
    resp = self._pool.handle_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpcore\_sync\connection_pool.py", line 167, in handle_request
    raise UnsupportedProtocol(
httpcore.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\openai\_base_client.py", line 918, in _request
    response = self._client.send(
               ^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_client.py", line 914, in send
    response = self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_client.py", line 942, in _send_handling_auth
    response = self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_client.py", line 979, in _send_handling_redirects
    response = self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_client.py", line 1015, in _send_single_request
    response = transport.handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_transports\default.py", line 232, in handle_request
    with map_httpcore_exceptions():
  File "C:\Program Files\Python312\Lib\contextlib.py", line 155, in __exit__
    self.gen.throw(value)
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\httpx\_transports\default.py", line 86, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\Scripts\praisonai.exe\__main__.py", line 7, in <module>
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\praisonai\__main__.py", line 7, in main
    praison_ai.main()
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\praisonai\cli.py", line 69, in main
    self.agent_file = generator.generate()
                      ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\praisonai\auto.py", line 45, in generate
    response = self.client.chat.completions.create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\instructor\patch.py", line 570, in new_create_sync
    response = retry_sync(
               ^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\instructor\patch.py", line 387, in retry_sync
    for attempt in max_retries:
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\tenacity\__init__.py", line 435, in __iter__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\tenacity\__init__.py", line 368, in iter
    result = action(retry_state)
             ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\tenacity\__init__.py", line 410, in exc_check
    raise retry_exc.reraise()
          ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\tenacity\__init__.py", line 183, in reraise
    raise self.last_attempt.result()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\concurrent\futures\_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python312\Lib\concurrent\futures\_base.py", line 401, in __get_result
    raise self._exception
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\instructor\patch.py", line 390, in retry_sync
    response = func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\openai\_utils\_utils.py", line 275, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\openai\resources\chat\completions.py", line 663, in create
    return self._post(
           ^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\openai\_base_client.py", line 1200, in post
    return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\openai\_base_client.py", line 889, in request
    return self._request(
           ^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\openai\_base_client.py", line 942, in _request
    return self._retry_request(
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\openai\_base_client.py", line 1013, in _retry_request
    return self._request(
           ^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\openai\_base_client.py", line 942, in _request
    return self._retry_request(
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\openai\_base_client.py", line 1013, in _retry_request
    return self._request(
           ^^^^^^^^^^^^^^
  File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\openai\_base_client.py", line 952, in _request
    raise APIConnectionError(request=request) from err
openai.APIConnectionError: Connection error.
oldlastman commented 1 month ago

Hi,

Actually, I forgot about this and tried other methods to get agents. Just in case, I will try again now and use:

  1. Ollama with model Ollama 3.
  2. Setting environment variables like:
    $env:OPENAI_API_BASE='http://localhost:11434/v1'
    $env:OPENAI_MODEL_NAME='llama3'
    $env:OPENAI_API_KEY='NA'
  3. Launching the init command like: praisonai --init your desired task

Note: I tried Mixtral, but it didn't work.

It looks like it initialized well. Then, as stated in the instructions, launching "praisonai" appears to be working as it even receives a "done" answer.


Looking into your error:

File "C:\Users\zhanshib\AppData\Roaming\Python\Python312\site-packages\openai\_base_client.py", line 952, in _request
    raise APIConnectionError(request=request) from err
openai.APIConnectionError: Connection error.

Are you sure you declared your OpenAI keys correctly? And if you are trying to connect to Ollama, did you declare your environment variables? (I set an example previously.)

I can't help anymore, sorry, I'm not an expert.