Spaces:
Sleeping
Sleeping
| from groq import Groq | |
| from dotenv import load_dotenv | |
| import os | |
| load_dotenv() | |
| groq_api_key=os.getenv("groq_api_key") | |
| client = Groq(api_key=groq_api_key) | |
| def ask_ai_movie(text:str): | |
| prompt=""""You are a movie and TV show identification engine. | |
| Task: | |
| You will receive an overview, reference, description, or short storyline of a movie, TV show, web series, or animated series. | |
| Rules: | |
| - Identify the most likely matching title. | |
| - Return ONLY the official name of the movie or TV show. | |
| - Do NOT add explanations, descriptions, years, emojis, punctuation, or extra text. | |
| - If multiple versions exist, return the most popular or original one. | |
| - If it is a TV show or series, return the series name only. | |
| - If you are unsure, return the single best guess. | |
| - If nothing matches confidently, return: Unknown""" | |
| chat_completion = client.chat.completions.create( | |
| messages=[ | |
| { | |
| "role": "system", | |
| "content": prompt | |
| }, | |
| { | |
| "role": "user", | |
| "content": text, | |
| } | |
| ], | |
| model="llama-3.3-70b-versatile", | |
| temperature=0.6 | |
| ) | |
| return chat_completion.choices[0].message.content | |