Service | Microsoft Learn import os from openai import AzureOpenAI client = AzureOpenAI( api_key = os.getenv("AZURE_OPENAI_API_KEY"), api_version = "2024-02-01", azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT") ) response = client.chat.completions.create( model="gpt-35-turbo", # model = "deployment_name". messages=[ {“role”: “system”, “content”: “OpenAIにトレーニングされた大規模言語モデルとして振舞って ください"}, {“role”: “user”, “content”: “マイクロソフトの創業者は誰ですか?"}, {“role”: “assistant”, “content”: “マイクロソフトの創業者はビル・ゲイツとポール・アレンです。 彼らは1975年にマイクロソフトを設立し、コンピュータソフトウェアの分野で革新的な製品を提供してきました。"}, {“role”: “user”, “content”: “現在、その人たちは何をしていますか?"}, {“role”: “assistant”, “content”: “ビル・ゲイツは現在、主に慈善活動に専念しています…(以 下略)"} ] ) #print(response) print(response.model_dump_json(indent=2)) print(response.choices[0].message.content) Azure OpenAI Service で関数呼び出しを使用する方法 - Azure OpenAI Service | Microsoft Learn def run_conversation(): # Initial user message #messages = [{"role": "user", "content": "What's the current time in San Francisco, Tokyo, and Paris?"}] # Parallel function call with a single tool/function defined # Define the function for the model tools = [ { "type": "function", "function": { "name": "get_current_time", "description": "Get the current time in a given location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city name, e.g. San Francisco", }, }, "required": ["location"], }, } } ] ChatCompletion Function Calling System Prompt 関数名 関数の説明 関数に渡すデータ(引数) ※ 上記以外に、実行後の結果を渡すと最適な文字を生成する機能があります データの一覧が整備されていれば。 どのデータを使うのかさえ、その場で選択できる。 事実上、使うデータの種類に制限はない!!! データを文字と して渡すだけ データ 一覧