PauleanPrompt / usage_example.py
roneymatusp's picture
Upload usage_example.py with huggingface_hub
53ea537 verified
import json
from ollama import Client
# Load system prompt
with open('system_prompt.json', 'r') as f:
config = json.load(f)
SYSTEM_PROMPT = config['system_prompt']
# Initialize client
client = Client(
host="https://ollama.com",
headers={'Authorization': 'YOUR_OLLAMA_API_KEY'}
)
# Optimize a prompt
def optimize_prompt(input_text):
response = client.chat(
model="gpt-oss:20b",
messages=[
{'role': 'system', 'content': SYSTEM_PROMPT},
{'role': 'user', 'content': input_text}
],
options={'temperature': 0.7}
)
return response['message']['content']
# Example usage
print(optimize_prompt("como fazer uma aula boa?"))