Skip to main content
Glama
Harnishnava

pokemon-api-server

backend.cpython-313.pyc4.58 kB
� �U�g& ���SSKJrJr SSKJr SSKrSSKrSSKJr SSK r SSK J r SSK J r SSKJrJr SSKr\"5 \"5r\R'\S/S S/S/S 9 S r\ R*"\S 9 \ "\S 9rSrSr\"5r\R5S5S5r\R9S5S\4Sj5r\R5S5S\4Sj5rg)�)�FastAPI� HTTPException)�CORSMiddlewareN)� load_dotenv)�GooglePalmEmbeddings)�Chroma)�List�Dict�*T)� allow_origins�allow_credentials� allow_methods� allow_headers�8gsk_iY1tPczldFNwoQfAxz5uWGdyb3FYFv84VWNgub749sA73z0i3C5s)�api_key)�google_api_keyzhttps://pokeapi.co/api/v2c �N�[R"[S35nUR5Sn/nUH�n[R"US5R5nSUSS3nUSSR US Vs/sH ofS SPM sn5S3- nUS US S3- nUS USS3- nUSUSS3- nUSSR USVs/sH owSSPM sn5S3- nUR U5 M� [ R"U[SS9nU$s snfs snf)Nz/pokemon?limit=100�results�urlzName: �name� zTypes: z, �types�typezHeight: �heightzWeight: �weightzBase Experience: �base_experiencez Abilities: � abilities�ability�pokemon_collection)�collection_name) �requests�get�POKE_API_BASE_URL�json�join�appendr� from_texts� embeddings) �response� pokemon_list�texts�pokemon� pokemon_data�text�t�a� vector_stores �7C:\Users\harni\Desktop\New folder\pokemon ai\backend.py�initialize_vector_storer3&sg���|�|�0�1�1C�D�E�H��=�=�?�9�-�L� �E����|�|�G�E�N�3�8�8�:� �� �V�,�-�R�0�� �'�$�)�)� �W�@U�$V�@U�1�v�Y�v�%6�@U�$V�W�X�XZ�[�[�� �(�<��1�2�"�5�5�� �(�<��1�2�"�5�5�� �#�L�1B�$C�#D�B�G�G�� �+�d�i�i�|�T_�G`�(a�G`�!�9��f�)=�G`�(a�b�c�ce�f�f�� � � �T�� ��$�$� ��,��L� ���%W��)bs �<D�D"�/c��# �SS0$7f)N�messagezPokemon RAG AI API is running�r7�r2�rootr9As��� �6� 7�7�s�z/chat�queryc��X# �[RUSS9nSRUVs/sHo"RPM sn5nSUSUS3n[R "S5nUR U5nSUR0$s snf![an[S [U5S 9eSnAff=f7f) N�)�krz4Based on the following Pokemon information: z( Answer this question: z> Provide a detailed and informative response.zmodels/text-bison-001r)i��� status_code�detail) r1�similarity_searchr%� page_content�genai�GenerativeModel� generate_text�result� Exceptionr�str)r:�search_results�doc�context�prompt�modelr)�es r2�chatrOEs����<�%�7�7���7�C���)�)��H��#�-�-��H�I�� � � ��$�g�&5�8���%�%�&=�>���&�&�v�.���H�O�O�,�,��I�� �<���C��F�;�;��<�s9�B*�#B�B�AB�?B*�B� B'�B"�"B'�'B*z/pokemon/{pokemon_name}� pokemon_namec���# �[R"[SUR535nUR 5$![ an[ SSUS3S9eSnAff=f7f)Nz /pokemon/i�zPokemon z not foundr>)r!r"r#�lowerr$rGr)rPr)rNs r2� get_pokemonrS\sc���Y��<�<�#4�"5�Y�|�?Q�?Q�?S�>T� U�V���}�}���� �Y���h�|�n�J�4W�X�X��Y�s(�A!�<A�A!� A� A�A�A!) �fastapirr�fastapi.middleware.corsrr!�os�dotenvrrC�langchain.embeddingsr�langchain.vectorstoresr�typingr r r$�app�add_middleware�GOOGLE_API_KEY� configurer(r#r3r1r"r9�postrHrOrSr7r8r2�<module>r`s���*�2�� �� �5�)�� � � ��i�������%���%��%� ��L������'�"�� @� �0���2'�(� ������8��8����'��<�c�<��<�,��� "�#�Y�C�Y�$�Yr8

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Harnishnava/pokemon-ai'

If you have feedback or need assistance with the MCP directory API, please join our Discord server