Need Temperature/Max_token Options #114

Closed
opened 2026-02-15 16:28:04 -05:00 by yindo · 3 comments
Owner

Originally created by @cytusbox on GitHub (Jul 17, 2024).

My python script:

from ollama import Client
client = Client(host=args.base_url)
chat_completion = client.chat(
    messages=[
        {
            "role": "user",
            "content": full_prompt,
        },
    ],
    model=args.model,
    temperature = args.temp # TO SET THE TEMPERATURE OF MODEL
)

Is there any way to set temperature/max_token options through python api?

Originally created by @cytusbox on GitHub (Jul 17, 2024). My python script: ```python from ollama import Client client = Client(host=args.base_url) chat_completion = client.chat( messages=[ { "role": "user", "content": full_prompt, }, ], model=args.model, temperature = args.temp # TO SET THE TEMPERATURE OF MODEL ) ``` Is there any way to set temperature/max_token options through python api?
yindo closed this issue 2026-02-15 16:28:04 -05:00
Author
Owner

@Orest02 commented on GitHub (Jul 19, 2024):

there's an API documentation that gives a deeper insight on additional parameters you can use, you might be looking for this section:
https://github.com/ollama/ollama/blob/main/docs/api.md#generate-request-with-options

@Orest02 commented on GitHub (Jul 19, 2024): there's an API documentation that gives a deeper insight on additional parameters you can use, you might be looking for this section: https://github.com/ollama/ollama/blob/main/docs/api.md#generate-request-with-options
Author
Owner

@cytusbox commented on GitHub (Jul 19, 2024):

这是来自QQ邮箱的假期自动回复邮件。
 
您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

@cytusbox commented on GitHub (Jul 19, 2024): 这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
Author
Owner

@lennartpollvogt commented on GitHub (Jul 22, 2024):

The chat function has the argument options (a dictionary) to provide such configurations. Here is an example for setting the temperature.

from ollama import Client
client = Client(host=args.base_url)
chat_completion = client.chat(
    messages=[
        {
            "role": "user",
            "content": full_prompt,
        },
    ],
    model=args.model,
    options={"temperature":0.5}
)

You will find in the docs of the Ollama repository the full documentation of these options (see comment above)

@lennartpollvogt commented on GitHub (Jul 22, 2024): The chat function has the argument `options` (a dictionary) to provide such configurations. Here is an example for setting the temperature. ```Python from ollama import Client client = Client(host=args.base_url) chat_completion = client.chat( messages=[ { "role": "user", "content": full_prompt, }, ], model=args.model, options={"temperature":0.5} ) ``` You will find in the docs of the Ollama repository the full documentation of these options (see comment above)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#114