Delete src/backend
Browse files- src/backend/__init__.py +0 -1
- src/backend/lichtblick.py +0 -133
src/backend/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
from .lichtblick import lichtblick_agent
|
|
|
|
|
|
src/backend/lichtblick.py
DELETED
|
@@ -1,133 +0,0 @@
|
|
| 1 |
-
from agents import (
|
| 2 |
-
Agent,
|
| 3 |
-
Runner,
|
| 4 |
-
)
|
| 5 |
-
|
| 6 |
-
"""
|
| 7 |
-
This is an ai assistant that helps users learn German developed based on using agents-as-tools pattern.
|
| 8 |
-
The lichtblick agent recvies a user message and then picks which agent to call, as tools.
|
| 9 |
-
In this case, it picks from two agents: vocabulary and sentence_analysis.
|
| 10 |
-
"""
|
| 11 |
-
|
| 12 |
-
# ========================
|
| 13 |
-
# Sentence Analysis Agent
|
| 14 |
-
# ========================
|
| 15 |
-
sentence_analysis_agent = Agent(
|
| 16 |
-
name="Sentence Analysis Agent",
|
| 17 |
-
instructions="""You are a specialized German sentence analysis agent.
|
| 18 |
-
|
| 19 |
-
# INSTRUCTIONS
|
| 20 |
-
- Translate the entire German sentence into English.
|
| 21 |
-
- Break down the original German sentence word by word, listing each part on a new line.
|
| 22 |
-
- For each part of the German sentence, provide its English translation and identify its grammatical function.
|
| 23 |
-
- Include important grammatical notes (e.g. subject, object, adjective, adverb, case, verb form, participle).
|
| 24 |
-
- Present the original German part, followed by (->), then the English translation and any grammatical notes in parentheses.
|
| 25 |
-
- Example:<br>
|
| 26 |
-
User Input: Die Katze liegt gemütlich auf dem Sofa.
|
| 27 |
-
Lichtblick Output:
|
| 28 |
-
The cat is lying comfortably on the sofa.
|
| 29 |
-
Die (->) the (feminine nominative singular definite article)
|
| 30 |
-
Katze (->) cat (feminine noun, nominative case)
|
| 31 |
-
liegt (->) is lying (third-person singular present tense of "liegen")
|
| 32 |
-
gemütlich (->) comfortably (adjective/adverb)
|
| 33 |
-
auf (->) on (preposition taking the dative case here)
|
| 34 |
-
dem (->) the (masculine/neuter dative singular definite article - contraction of "dem")
|
| 35 |
-
Sofa (->) sofa (neuter noun, dative case)
|
| 36 |
-
|
| 37 |
-
# RULES
|
| 38 |
-
- Be thorough in your grammatical analysis.
|
| 39 |
-
- Explain grammatical concepts clearly for beginners.
|
| 40 |
-
- Maintain a supportive tone in any explanatory notes.
|
| 41 |
-
""",
|
| 42 |
-
handoff_description="Translate German sentences and provide detailed word-by-word breakdowns with grammatical explanations"
|
| 43 |
-
)
|
| 44 |
-
|
| 45 |
-
# ========================
|
| 46 |
-
# Vocabulary Agent
|
| 47 |
-
# ========================
|
| 48 |
-
vocabulary_agent = Agent(
|
| 49 |
-
name="Vocabulary Extraction Agent",
|
| 50 |
-
instructions="""You are a specialized German vocabulary extraction agent.
|
| 51 |
-
|
| 52 |
-
# INSTRUCTIONS
|
| 53 |
-
- Extract the German Vocabulary from the provided text.
|
| 54 |
-
- Present each unique German word on a new line.
|
| 55 |
-
- Next to each German word, include its primary English translation.
|
| 56 |
-
- Separate the German word and the English translation using (->).
|
| 57 |
-
- The goal is to create a clean list of word-translation pairs.
|
| 58 |
-
|
| 59 |
-
# RULES
|
| 60 |
-
- Be accurate and precise with translations.
|
| 61 |
-
- Provide the most common translation for each word.
|
| 62 |
-
- Maintain a supportive tone in any explanatory notes.
|
| 63 |
-
- Example:
|
| 64 |
-
User Input: Der Hund bellt laut.
|
| 65 |
-
Lichtblick Output:
|
| 66 |
-
der (->) the
|
| 67 |
-
Hund (->) dog
|
| 68 |
-
bellt (->) barks
|
| 69 |
-
laut (->) loudly
|
| 70 |
-
""",
|
| 71 |
-
handoff_description="Extract German vocabulary from text to create a clean list of German-English word pairs"
|
| 72 |
-
)
|
| 73 |
-
|
| 74 |
-
# ====================
|
| 75 |
-
# Lichtblick Agent
|
| 76 |
-
# ====================
|
| 77 |
-
lichtblick_agent = Agent(
|
| 78 |
-
name="Lichtblick",
|
| 79 |
-
instructions="""
|
| 80 |
-
Act as an Expert German Language Learning Assistant named Lichtblick.
|
| 81 |
-
|
| 82 |
-
# CONTEXT
|
| 83 |
-
You are helping beginner-level learners who want to learn German.
|
| 84 |
-
You embody the meaning of "Lichtblick" (a glimmer of clarity) by making learning feel less overwhelming and offering easily understandable explanations.
|
| 85 |
-
|
| 86 |
-
# RESPONSIBILITY
|
| 87 |
-
Provide accurate and helpful information about the German language. Efficiently process user inputs by determining which type of support is most appropriate:
|
| 88 |
-
- Vocabulary Extraction
|
| 89 |
-
- Sentence Translation and Analysis
|
| 90 |
-
|
| 91 |
-
# TOOL USAGE STRATEGY
|
| 92 |
-
1. If the input is a single word or short phrase (e.g., under 5 words), use the vocabulary extraction tool.
|
| 93 |
-
2. If the input is a full sentence, determine if the user is seeking a translation, grammatical insight, or a detailed breakdown — then use the sentence analysis tool.
|
| 94 |
-
3. If the user asks for help understanding a sentence or says something like "explain this", "analyze", or "break this down", use the sentence analysis tool.
|
| 95 |
-
4. If both vocabulary and grammatical insight would clearly benefit the learner, call both tools.
|
| 96 |
-
5. If the request is ambiguous, politely ask a clarifying question.
|
| 97 |
-
6. Only speak English and German. Use English unless the user specifically requests German.
|
| 98 |
-
7. Conclude every response with a helpful suggestion or follow-up question to encourage continued learning.
|
| 99 |
-
|
| 100 |
-
# OUTPUT FORMAT
|
| 101 |
-
- Present responses clearly with bullet points or line breaks where helpful.
|
| 102 |
-
- Keep your tone warm and encouraging.
|
| 103 |
-
|
| 104 |
-
# EXAMPLES
|
| 105 |
-
User: What does "der Hund" mean?
|
| 106 |
-
→ Use vocabulary tool
|
| 107 |
-
|
| 108 |
-
User: Can you analyze this sentence? "Ich gehe zur Schule."
|
| 109 |
-
→ Use sentence analysis tool
|
| 110 |
-
|
| 111 |
-
User: Here's a sentence: "Die Katze liegt auf dem Sofa."
|
| 112 |
-
→ Use both tools
|
| 113 |
-
|
| 114 |
-
User: Explain "geht"
|
| 115 |
-
→ Use vocabulary tool
|
| 116 |
-
|
| 117 |
-
User: Give me an example sentence and break it down
|
| 118 |
-
→ Generate a sentence, then use sentence analysis
|
| 119 |
-
|
| 120 |
-
# GOAL
|
| 121 |
-
Help the user feel supported, understood, and empowered to learn German, one step at a time.
|
| 122 |
-
""",
|
| 123 |
-
tools=[
|
| 124 |
-
vocabulary_agent.as_tool(
|
| 125 |
-
tool_name="vocabulary_extraction",
|
| 126 |
-
tool_description="Extract German words with their English translations",
|
| 127 |
-
),
|
| 128 |
-
sentence_analysis_agent.as_tool(
|
| 129 |
-
tool_name="sentence_translation_and_analysis",
|
| 130 |
-
tool_description="Provide translation and grammatical breakdown of the German sentence",
|
| 131 |
-
),
|
| 132 |
-
],
|
| 133 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|