-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_usage.py
More file actions
30 lines (26 loc) · 839 Bytes
/
example_usage.py
File metadata and controls
30 lines (26 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
Beispiel: AcademicAI verwenden.
Credentials werden aus .env geladen.
"""
import academicai
# Verfügbare Modelle abrufen
print("=== Verfügbare Modelle ===")
models = academicai.get_models()
for m in models["data"]:
print(f" - {m['id']} (context: {m.get('context_window', '?')})")
# Einfache Chat-Anfrage
print("\n=== Chat Completion ===")
response = academicai.completion(
model="gpt-4o",
messages=[
{"role": "user", "content": "Erkläre kurz den Begriff 'Micro-Credential'."}
],
)
print(response.choices[0].message.content)
print(f"\nToken-Usage: {response.usage}")
# Mit RAG / Tailored AI
# response_rag = academicai.completion(
# model="gpt-4o",
# messages=[{"role": "user", "content": "Was steht in meiner Knowledge Base?"}],
# extra_body={"tailoredAiId": "your-tailored-ai-id-here"},
# )