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

System Message causing no answer from Assistant #72

Open
pedrognsmartins opened this issue Feb 20, 2024 · 5 comments
Open

System Message causing no answer from Assistant #72

pedrognsmartins opened this issue Feb 20, 2024 · 5 comments

Comments

@pedrognsmartins
Copy link

Hello all,

I´m trying to use the system message as described below. Evertytime I use it I don´t have any answer from the LLM.

    messages = [
        {'role': 'system', 'content': f'"{self.role}"'},
        {'role': 'user', 'content': f'"{message}"'},
    ]
    return await client.chat(model=model, messages=messages,)

I was trying to find if there is any issue reported but I didn´t found it. Can someone help me on this ?

Thanks

@connor-makowski
Copy link

For general use as shown in most examples, you should have a local ollama server running to be able to continue.

To do this:

  • Download: https://ollama.com/
  • In your terminal, run an LLM:
  • If you want to use a non local server (or a different local one), see the docs on Custom Client

@connor-makowski
Copy link

This is verbage as part of the PR: #64

@connor-makowski
Copy link

connor-makowski commented Feb 21, 2024

It is also worth noting that you are using an await. Are you using an async client?

For a non async client you do not need await:

import ollama
response = ollama.chat(model='llama2', messages=[
  {
    'role': 'user',
    'content': 'Why is the sky blue?',
  },
])
print(response['message']['content'])

For an async client, you should use an await.

import asyncio
from ollama import AsyncClient

async def chat():
  message = {'role': 'user', 'content': 'Why is the sky blue?'}
  response = await AsyncClient().chat(model='llama2', messages=[message])

asyncio.run(chat())

@pedrognsmartins
Copy link
Author

@connor-makowski Thanks for your feedback. I used both solution (sync and Async clients). the problem is that when assuming a message with Role: System, LLM is not giving answer.

@mxyng
Copy link
Collaborator

mxyng commented Mar 1, 2024

what model are you using?

your snippet doesn't stream. is it possible the llm is responding but hasn't completed yet? in this mode, ollama will wait until it has the full response before returning to the call. this could look like non-response if it's also generating tokens at a slow rate (due to hardware limitations)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants