File size: 820 Bytes
525c716
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6c8a2d5
525c716
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import asyncio  # <-- Import asyncio
from backend.utils import get_completion
from backend.config import CURRICULUM_INSTRUCTIONS

# Define an async function to hold the await call
async def main():
    query = "need to improve my chinese so as to propose to my girlfriend"
    print("Getting completion...") # Optional: Indicate progress
    try:
        response = await get_completion(prompt=query, instruction=CURRICULUM_INSTRUCTIONS)
        print("\nResponse:")
        print(response)
    except Exception as e:
        print(f"An error occurred: {e}") # Basic error handling

# Use asyncio.run() to execute the async main function
# The if __name__ == "__main__": block ensures this runs only when
# the script is executed directly (e.g., python -m backend.main)
if __name__ == "__main__":
    asyncio.run(main())