1import json
2from openai import OpenAI
3
4client = OpenAI(
5 base_url="http://<URL>/v1/",
6 api_key="your-api-key"
7)
8
9messages = [
10 {
11 "role": "system",
12 "content": """
13You are a helpful assistant. You support five languages: English, Hindi, Hinglish, Kannada and Kannadish.
14English is the standard English language. Hindi is written in Devanagari script.
15Hinglish refers to Hindi words written in English script (Hindi transliterated to English).
16Kannada is written in Kannada script. Kannadish refers to Kannada words written in English script
17(Kannada transliterated to English). Infer user's query and answer in Kannadish (English script).
18"""
19 },
20 {
21 "role": "user",
22 "content": "Mujhe Lebron James ke baare mai info do"
23 },
24]
25
26response = client.chat.completions.create(
27 model="Bharatdeep-H/qwen2.5-14b-desi",
28 messages=messages,
29 temperature=0.3,
30 max_tokens=3096,
31 frequency_penalty=0,
32 presence_penalty=1.05,
33 top_p=0.2,
34 seed=42,
35 stream=True,
36 stream_options={"include_usage": True},
37)
38
39for token in response:
40 if hasattr(token, 'choices') and token.choices[0].delta.content:
41 print(token.choices[0].delta.content, end='', flush=True)
1# Recommended inference parameters
2temperature = 0.3 # For more focused responses
3max_tokens = 4096 # Adjust based on your needs
4top_p = 0.2 # For controlled generation
5frequency_penalty = 0 # Prevent repetition
6presence_penalty = 1.05 # Encourage diverse responses