roneymatusp commited on
Commit
53ea537
·
verified ·
1 Parent(s): 90da011

Upload usage_example.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. usage_example.py +28 -0
usage_example.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from ollama import Client
3
+
4
+ # Load system prompt
5
+ with open('system_prompt.json', 'r') as f:
6
+ config = json.load(f)
7
+ SYSTEM_PROMPT = config['system_prompt']
8
+
9
+ # Initialize client
10
+ client = Client(
11
+ host="https://ollama.com",
12
+ headers={'Authorization': 'YOUR_OLLAMA_API_KEY'}
13
+ )
14
+
15
+ # Optimize a prompt
16
+ def optimize_prompt(input_text):
17
+ response = client.chat(
18
+ model="gpt-oss:20b",
19
+ messages=[
20
+ {'role': 'system', 'content': SYSTEM_PROMPT},
21
+ {'role': 'user', 'content': input_text}
22
+ ],
23
+ options={'temperature': 0.7}
24
+ )
25
+ return response['message']['content']
26
+
27
+ # Example usage
28
+ print(optimize_prompt("como fazer uma aula boa?"))