Spaces:
Runtime error
Runtime error
| #from pydantic_ai.result import ResultData | |
| import streamlit as st | |
| from pydantic_ai import Agent | |
| from pydantic_ai.models.groq import GroqModel | |
| from pydantic_ai.models.anthropic import AnthropicModel | |
| from pydantic_ai.models.mistral import MistralModel | |
| import nest_asyncio | |
| import random | |
| import planet_model as customModel | |
| from typing import List, Dict | |
| import constants | |
| import os | |
| api_key = os.getenv("api_key") | |
| random_number = random.randint(3000, 10000) | |
| model = MistralModel('mistral-small-latest', api_key = 'ZGs1ZTvw6csiboQnBC9mi1cmsBjAPRu7') | |
| async def onClick(vacationType,familyType,duration,purpose,interests): | |
| agent = Agent(model,system_prompt=( | |
| "You are a highly advanced travel agent specializing in intergalactic vacations", | |
| "Planet Name: A creative, fictional planet name.", | |
| f"imagine the year is {random_number} and space travel is normal", | |
| "Mankind has discovered aliens some are more advance then us some are not", | |
| "You are a travel agent and depending on the" + vacationType +"you will list down alteast 5 destinations", | |
| "Also answer based on "+familyType+ "," + duration +","+purpose + "and"+interests, | |
| "Be creative made-up different kinds of planets, aliens, atmosphere", | |
| "Draw inspiration from sources like No Man’s Sky, Hitchhiker’s Guide to the Galaxy, and original creative ideas. Be imaginative, and ensure variety in your suggestions to cater to different tastes.", | |
| "Cosmic Myths: Stories from Norse (Yggdrasil), Hindu (Churning of the Ocean), or Aboriginal (Dreamtime) traditions.", | |
| "Alien Archetypes: Trickster gods, celestial guardians, or ancient interstellar ruins.", | |
| "Astrobiology: Speculate on alien life forms based on real theories (e.g., extremophiles or silicon-based life).", | |
| "Physics: Use concepts like wormholes, Dyson spheres, or FTL (faster-than-light) travel.", | |
| "Exoplanet Studies: Real planets discovered by NASA or ESA (e.g., TRAPPIST-1 system).", | |
| "Utopian/Dystopian Visions: Consider societal structures from Brave New World or 1984.", | |
| "Cultural Exchange: Speculate on how humans and aliens might interact, inspired by Arrival.", | |
| "Music: Cosmic and futuristic soundscapes from artists like Vangelis (Blade Runner soundtrack) or Daft Punk (Tron soundtrack).", | |
| "Visual Arts: Imagery from H.R. Giger (Alien) or Moebius (The Incal).", | |
| "Graphic Novels: Saga, Transmetropolitan.", | |
| "Each recommendation should include:", | |
| "The planet's name and description of its atmosphere.", | |
| "Details about the local alien species and their culinary traditions.", | |
| "A signature dish or food experience.", | |
| "Key activities or attractions for a traveler interested in food and culture." | |
| ), | |
| ) | |
| result_1 = agent.run_sync(user_prompt="for space travel which planet is the best") | |
| result = result_1 | |
| st.caption(result.data) | |
| print(result_1) | |
| def asyncOnClick(vacationType,familyType,duration,purpose,interests): | |
| asyncio.run(onClick(vacationType,familyType,duration,purpose,interests)) | |
| async def main(): | |
| #result_1 = agent.run_sync("for space travel which planet is the best") | |
| ##The Zorvath | |
| #print(result_1.data) | |
| #result_2 = agent.run_sync("What are the major tourust attraction in planet The Zorvath",message_history=result_1.new_messages()) | |
| #print(result_2.data) | |
| #st.markdown(result_1.data) | |
| #st.button(label="Search",type="primary",on_click=onClick) | |
| st.subheader("Travel Preferences") | |
| vacationType = st.selectbox(label="Travel Style",options=("Budget","Mid-budget","High-end")) | |
| family = st.selectbox(label="Group Size",options=("Solo","Small family","Large family","Destination weeding")) | |
| duration = st.selectbox(label="Duration of Trip",options=("5 days","2 weeks","1 month","more then 1 month")) | |
| purpose = st.selectbox(label="Purpose of Travel",options=("Honeymoon","anniversary","family vacation","corporate retreat","vacation","Food tour")) | |
| interests = st.selectbox(label="Special Interestl",options=("Photography","gastronomy","wildlife","art")) | |
| if st.button("Search"): | |
| asyncOnClick(vacationType,family,duration,purpose,interests) | |
| vacationType = "" | |
| family = "" | |
| duration = "" | |
| purpose = "" | |
| interests = "" | |
| if __name__ == '__main__': | |
| import asyncio | |
| nest_asyncio.apply() | |
| asyncio.run(main()) | |