Giter Club home page Giter Club logo

Comments (15)

valentimarco avatar valentimarco commented on September 28, 2024 5

#783 Will gonna resolve most problem with ollama, wait some time

from core.

valentimarco avatar valentimarco commented on September 28, 2024 2

@enrichicco thank you for the effort you are putting! We already resolve the problem with the merge of #783 #813 in develop branch.
To summarize the problem:

  1. Langchain patched all problems with Ollama (before that we used the ollama_utils.py to patch some issues)
  2. Ollama update the body of the APIs (this is why we have the error)

With the new changes, we also resolve the tool selection issue when a local model tries to select a tool (now even Phi-3 can launch tools)

from core.

mecodj avatar mecodj commented on September 28, 2024 1

ok... I am back... I was able to obtain at least one answer.

It seems that the problem is in the file (inside the docker backend container):

/app/cat/looking_glass/agent_manager.py

I changed the line 170, from

return await memory_chain.ainvoke({**agent_input, "stop": "Human:"}, config=RunnableConfig(callbacks=[NewTokenHandler(stray)]))

to

return await memory_chain.ainvoke({**agent_input, "stop":["Human:"]}, config=RunnableConfig(callbacks=[NewTokenHandler(stray)]))

and the call apparently worked... again, take this with caution: smally tested (just one shot), from a beginner on both sides (python api and ollama api interface)

I solved it like this too

from core.

Pingdred avatar Pingdred commented on September 28, 2024 1

@Pingdred do you know if this fix needs to apply also for the new chain?

Not for now because we no longer use the stop sequence (branch develop), however, there is to test and see if it is necessary to keep it

from core.

bositalia avatar bositalia commented on September 28, 2024

Confirm possible bug with Ollama 1.33 and Qdrant 1.9.1, same problem.

from core.

enrichicco avatar enrichicco commented on September 28, 2024

First of all, really great job, ceshire-cat is great.

Then...

Please, take my observation with some caution, since I am fairly new to this kind of environment.
Maybe, I am writing a lot of rubbish...

It seems that here there are two problems:

  1. the first is in the ceshire-cat, core application, code file:

[prjroot_core]/cat/factory/ollama_utils.py

where, at line 122, the handling of the exception passes through an async object, which "immediately" tries to call a get method on something which is not there yet:

            optional_detail = await response.json().get("error")

so the exception (I am inside the docker environment created through your compose file)

cheshire_cat_core           |   File "/app/cat/factory/ollama_utils.py", line 121, in _acreate_stream_patch
cheshire_cat_core           |     optional_detail = await response.json().get("error")
cheshire_cat_core           | AttributeError: 'coroutine' object has no attribute 'get'

My pesonal fix here, inspired by this stackoverflow post 'coroutine' object has no attribute get || pyppeteer

                    asy_optional_detail = await response.json()
                    optional_detail = asy_optional_detail.get("error")
  1. Apparently, with my fix, the exception catcher does catch the exception, which at the end is, on the web UI:

Ollama call failed with status code 500. Details: option "stop" must be of type array

here is an extract of the log inside the container:

cheshire_cat_core           |   File "/app/cat/factory/ollama_utils.py", line 123, in _acreate_stream_patch
cheshire_cat_core           |     raise ValueError(
cheshire_cat_core           | ValueError: Ollama call failed with status code 500. Details: option "stop" must be of type array

Which is the ollama exception.
On this one I am still lost.
I googled a little, giving the exact exception nothing was there.
I'll keep searching. however, still looking at the log, there are these two lines more or less immediately above the catcher:

cheshire_cat_core           |   File "/usr/local/lib/python3.10/site-packages/langchain_community/llms/ollama.py", line 343, in _astream_with_aggregation
cheshire_cat_core           |     async for stream_resp in self._acreate_generate_stream(prompt, stop, **kwargs):

which maybe could be interesting in order to solve this...

thank you again for this framework, really...

from core.

enrichicco avatar enrichicco commented on September 28, 2024

ok... I am back... I was able to obtain at least one answer.

It seems that the problem is in the file (inside the docker backend container):

/app/cat/looking_glass/agent_manager.py

I changed the line 170, from

return await memory_chain.ainvoke({**agent_input, "stop": "Human:"}, config=RunnableConfig(callbacks=[NewTokenHandler(stray)]))

to

return await memory_chain.ainvoke({**agent_input, "stop":["Human:"]}, config=RunnableConfig(callbacks=[NewTokenHandler(stray)]))

and the call apparently worked... again, take this with caution: smally tested (just one shot), from a beginner on both sides (python api and ollama api interface)

from core.

TobioDev avatar TobioDev commented on September 28, 2024

Appreciate it, @valentimarco! Any idea when we can expect this to be part of the main branch?

from core.

valentimarco avatar valentimarco commented on September 28, 2024

Appreciate it, @valentimarco! Any idea when we can expect this to be part of the main branch?

Appreciate it, @valentimarco! Any idea when we can expect this to be part of the main branch?

not soon, is already in the develop branch but need some testing. If you want you can try it and give a feedback

from core.

enrichicco avatar enrichicco commented on September 28, 2024

Hi @valentimarco,

I checked the commits and the development branch, and it seems to me that the coroutine object error is still there, i.e, this one:

         optional_detail = await response.json().get("error")

According to me, this should be something like this:

                    asy_optional_detail = await response.json()
                    optional_detail = asy_optional_detail.get("error")

it is not so bad, but in case of response codes != 200 and 404, it masks the (manually) raised value error (lets say, the real request exception) with the "coroutine object has no attribute get error" .

from core.

valentimarco avatar valentimarco commented on September 28, 2024

Hi @valentimarco,

I checked the commits and the development branch, and it seems to me that the coroutine object error is still there, i.e, this one:

         optional_detail = await response.json().get("error")

According to me, this should be something like this:

                    asy_optional_detail = await response.json()
                    optional_detail = asy_optional_detail.get("error")

it is not so bad, but in case of response codes != 200 and 404, it masks the (manually) raised value error (lets say, the real request exception) with the "coroutine object has no attribute get error" .

Langchain changed the code on that parts, infact i delete ollama_utils.py and from my test with ollama 1.33 and 1.34 i don't have any problem. If you want we can see it in discord, maybe i am forgetting something

from core.

valentimarco avatar valentimarco commented on September 28, 2024

@Pingdred do you know if this fix needs to apply also for the new chain?

from core.

greenmojo2 avatar greenmojo2 commented on September 28, 2024

Appreciate it, @valentimarco! Any idea when we can expect this to be part of the main branch?

Appreciate it, @valentimarco! Any idea when we can expect this to be part of the main branch?

not soon, is already in the develop branch but need some testing. If you want you can try it and give a feedback

I'm gonna apologize in advance for a dumb question: how do we switch to the develop branch? I followed the instructions here to install, but I can't figure out what the "image" line needs to be in order to use the develop branch (if that's even what you need to do lol)

If it isn't obvious, I am really new to docker and containerization. Thank you in advance!

from core.

valentimarco avatar valentimarco commented on September 28, 2024

Appreciate it, @valentimarco! Any idea when we can expect this to be part of the main branch?

Appreciate it, @valentimarco! Any idea when we can expect this to be part of the main branch?

not soon, is already in the develop branch but need some testing. If you want you can try it and give a feedback

I'm gonna apologize in advance for a dumb question: how do we switch to the develop branch? I followed the instructions here to install, but I can't figure out what the "image" line needs to be in order to use the develop branch (if that's even what you need to do lol)

If it isn't obvious, I am really new to docker and containerization. Thank you in advance!

  1. git clone https://github.com/cheshire-cat-ai/core.git
  2. git switch develop
  3. docker compose build
  4. docker compose up

from core.

greenmojo2 avatar greenmojo2 commented on September 28, 2024

Appreciate it, @valentimarco! Any idea when we can expect this to be part of the main branch?

Appreciate it, @valentimarco! Any idea when we can expect this to be part of the main branch?

not soon, is already in the develop branch but need some testing. If you want you can try it and give a feedback

I'm gonna apologize in advance for a dumb question: how do we switch to the develop branch? I followed the instructions here to install, but I can't figure out what the "image" line needs to be in order to use the develop branch (if that's even what you need to do lol)
If it isn't obvious, I am really new to docker and containerization. Thank you in advance!

  1. git clone https://github.com/cheshire-cat-ai/core.git
  2. git switch develop
  3. docker compose build
  4. docker compose up

Thank you so much!!! I cannot even begin to describe how excited I am to start experimenting with this!!!

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.