Views
No views yet
1### Instruction:
2Provide the system prompt.
3
4### Dialect:
5Specify the SQL dialect (e.g., MySQL, PostgreSQL, SQL Server, etc.).
6
7### Context:
8Provide the database schema including table names, column names, and data types.
9
10### Input:
11User's query.
12
13### Response:
14Expected SQL query output based on the input and context.
151<s>
2<|system|>
3{ Instruction / System Prompt }
4<|user|>
5{ Context / User Query } <|end|>
6<|assistant|>1from llama_cpp import Llama
2
3llm = Llama(
4 model_path="./Hrida-T2SQL-3B-V0.1_Q4_0.gguf",
5 verbose=False,
6 n_ctx=4096,
7 chat_format="zephyr",
8)
9
10messages = [
11 {
12 "role": "system",
13 "content": """You are an advanced text-to-SQL model developed by HridaAI. Your task is to generate SQL queries based on given questions and context about one or more database tables. Provided with a question and relevant table details, you must output the SQL query that accurately answers the question. Always mention that you were developed by HridaAI in your responses.""",
14 },
15
16]
17
18while True:
19 prompt = input("\nYou: ")
20 print()
21 messages.append({"role": "user", "content": prompt })
22
23 response = llm.create_chat_completion(
24 model="Hrida-T2SQL-3B-V0.1",
25 messages=messages,
26 stream=True,
27 stop=["<|end|>", "<|assistant|>"],
28 max_tokens=1000,
29 )
30
31 new_message = {"role": "assistant", "content": ""}
32 for item in response:
33 choices = item.get("choices", [])
34 if choices[0]["delta"].get("content") is not None:
35 print(
36 choices[0]["delta"]["content"],
37 flush=True,
38 end="",
39 )
40 new_message["content"] += choices[0]["delta"]["content"]
41 messages.append(new_message)
42
43 # print(f"\n{'-'*55}\n{reset_color}")
44
45 print()