CoolFace
Apppublic

howozn/IBM_Internship

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
models.cpython-312.pyc45 linesDownload Raw Back to __pycache__
1�

2nӷgT���d�Zd�Zd�Zy)c�~�i}gd�}d}|D]/}|dk(rt||�||<nt||||�||<|dz
}�1|S)uQ3    실제 모델 호출 대신 간단히 가상의 응답을 만듭니다.4    )�gemini-1.5-flash�ibm/granite-3-8b-instruct�&ibm/granite-3-2-8b-instruct-preview-rc� meta-llama/llama-3-1-8b-instruct��)�5GOOGLE_LLM�IBM_LLMS)�systemp�question�6model_list�	responses�7real_model�cnt�ms       �<c:\Users\ujinhong\Desktop\git\IBM_Internship\utils\models.py�simulate_model_responsesrs^���I�O�J�8�C�
���!�8�%�g�x�8�I�a�L�#�J�s�O�W�h�G�I�a�L��q������c�6�ddlm}ddlm}ddlm}ddlm}ddlm	}ddl9}d}	|�|jd�}10|jd	�}gd11�}|j|�dkrdn|j|�dz12}
||	|13��}|j|jj|j d
|j"d|j$d|j&d|j(di}|||||��}d|�d|�d�d|�d|�d�g}|j+||
d��}|�S)Nr)�GenTextParamsMetaNames)�DecodingMethods)�Credentials)�ModelInference��load_dotenvz!https://us-south.ml.cloud.ibm.com�api_key�14project_id)rrrr)�urlri�g�?�2)�model_id�params�credentialsra:15<|start_of_role|>system<|end_of_role|>16Knowledge Cutoff Date: April 2024.17Today's Date: December 16, 2024.18You are Granite, developed by IBM. You are a helpful AI assistant with access to the following tools. When a tool is required to answer the user's query, respond with <|tool_call|> followed by a JSON list of tools used. If a tool does not exist in the provided list of tools, notify the user that you do not have the ability to fulfill the request.19Answer questions briefly and do not provide unnecessary explanation.20You are a Korean model, SO ANSWER IN KOREAN.z).Don't fill in the format.21User question:z<|end_of_text|>aZ<|start_header_id|>system<|end_header_id|>22You always answer the questions with markdown formatting using GitHub syntax. 23The markdown formatting you support: headings, bold, italic, links, tables, lists, code blocks, and blockquotes. 24You must omit that you answer the questions with markdown.25Any HTML tags must be wrapped in block quotes, for example ```<html>```. 26You will be penalized for not rendering code in block quotes.27When returning code blocks, specify language.28You are a helpful, respectful and honest assistant. 29Always answer as helpfully as possible, while being safe.30Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. 31Please ensure that your responses are socially unbiased and positive in nature.32If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. 33If you don't know the answer to a question, please don't share false information.<|eot_id|><|start_header_id|>user<|end_header_id|>34Only answer questions concisely.35You are a Korean model, SO ANSWER IN KOREAN.F)�prompt�36guardrails)�ibm_watsonx_ai.metanamesr�,ibm_watsonx_ai.foundation_models.utils.enumsr�ibm_watsonx_air� ibm_watsonx_ai.foundation_modelsr�dotenvr�os�getenv�index�DECODING_METHOD�SAMPLE�value�MAX_NEW_TOKENS�MIN_NEW_TOKENS�TEMPERATURE�TOP_K�TOP_P�
generate_text)�	ibm_modelr�DATA�	GenParamsrrrrr*�Watsonx_ai_url�
IBM_Cloud_API�IBM_Project_ID�37ibm_models�Pindexr"�38parameters�model�
prompt_inputs�generated_responses                   rr39r40sL��L�L�*�?�"�
�8�N��M��I�I�i�(�M��Y�Y�|�,�N�x�J�� � ��+�Q�.�1�J�4D�4D�Y�4O�PQ�4Q�F��	�
��K�41���_�3�3�9�9����t����q����C��_�_�b��_�_�a�
�J�
���� �	
�E�-�.5�I�6��f�O�'�-�.5�I�6��f�O�'�(�M�0�,�,�M�&�4I�V[�,�\��!�"�$rc��ddlm}ddlm}ddl}|�|jd�}|}|j
|��|jd�}|j||z�}|jh}	t|	�djd�S)Nrr�google_api_key)rrz42?)�google.generativeai�generativeair)rr*r+�	configure�GenerativeModel�generate_content�text�list�strip)43rr7�genairr*�Google_Gemini_API�
SYSTEM_PROMPTr?�response�ress44          rr	r	^s~��'�"�
��M��	�	�"2�3���M�	�O�O�-�O�.��!�!�"4�5�E��%�%�m�d�&:�;�H��=�=�/�C���9�Q�<���e�$�$rN)rr45r	�rr�<module>rRs���*=%�F%r