Skip to content

Commit fef7022

Browse files
authored
Merge pull request #18 from Azure-Samples/fix/update-docs-responses-api
Update docs to reference Responses API instead of Chat Completions
2 parents cd06b0d + bf92dd0 commit fef7022

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

AGENTS.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ This document provides comprehensive instructions for coding agents working on t
44

55
## Overview
66

7-
This repository contains a collection of Python scripts that demonstrate how to use the OpenAI API (and compatible APIs like Azure OpenAI and Ollama) to generate chat completions. The repository includes examples of:
7+
This repository contains a collection of Python scripts that demonstrate how to use the OpenAI Responses API (and compatible APIs like Azure OpenAI and Ollama). The repository includes examples of:
88

9-
- Basic chat completions (streaming, async, history)
9+
- Basic responses (streaming, async, history)
1010
- Function calling (basic to advanced multi-function scenarios)
1111
- Structured outputs using Pydantic models
1212
- Retrieval-Augmented Generation (RAG) with various complexity levels
@@ -20,10 +20,10 @@ The scripts are designed to be educational and can run with multiple LLM provide
2020

2121
All example scripts are located in the root directory. They follow a consistent pattern of setting up an OpenAI client based on environment variables, then demonstrating specific API features.
2222

23-
**Chat Completion Scripts:**
24-
- `chat.py` - Simple chat completion example
25-
- `chat_stream.py` - Streaming chat completions
26-
- `chat_async.py` - Async chat completions with `asyncio.gather` examples
23+
**Chat Scripts:**
24+
- `chat.py` - Simple response example
25+
- `chat_stream.py` - Streaming responses
26+
- `chat_async.py` - Async responses with `asyncio.gather` examples
2727
- `chat_history.py` - Multi-turn chat with message history
2828
- `chat_history_stream.py` - Multi-turn chat with streaming
2929
- `chat_safety.py` - Content safety filter exception handling

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Python OpenAI demos
22

3-
This repository contains a collection of Python scripts that demonstrate how to use the OpenAI API to generate chat completions.
3+
This repository contains a collection of Python scripts that demonstrate how to use the OpenAI Responses API.
44
[📺 Watch this video walkthrough of running these demos in GitHub Codespaces](https://www.youtube.com/watch?v=_daw48A-RZI)
55

66
* [Examples](#examples)
7-
* [OpenAI Chat Completions](#openai-chat-completions)
7+
* [OpenAI Responses](#openai-responses)
88
* [Function calling](#function-calling)
99
* [Structured outputs](#structured-outputs)
1010
* [Retrieval-Augmented Generation (RAG)](#retrieval-augmented-generation-rag)
@@ -17,14 +17,14 @@ This repository contains a collection of Python scripts that demonstrate how to
1717

1818
## Examples
1919

20-
### OpenAI Chat Completions
20+
### OpenAI Responses
2121

22-
These scripts use the openai Python package to demonstrate how to use the OpenAI Chat Completions API.
22+
These scripts use the openai Python package to demonstrate how to use the OpenAI Responses API.
2323
In increasing order of complexity, the scripts are:
2424

25-
1. [`chat.py`](./chat.py): A simple script that demonstrates how to use the OpenAI API to generate chat completions.
26-
2. [`chat_stream.py`](./chat_stream.py): Adds `stream=True` to the API call to return a generator that streams the completion as it is being generated.
27-
3. [`chat_history.py`](./chat_history.py): Adds a back-and-forth chat interface using `input()` which keeps track of past messages and sends them with each chat completion call.
25+
1. [`chat.py`](./chat.py): A simple script that demonstrates how to use the OpenAI Responses API to generate a response.
26+
2. [`chat_stream.py`](./chat_stream.py): Adds `stream=True` to the API call to return a generator that streams the response text as it is being generated.
27+
3. [`chat_history.py`](./chat_history.py): Adds a back-and-forth chat interface using `input()` which keeps track of past messages and sends them with each API call.
2828
4. [`chat_history_stream.py`](./chat_history_stream.py): The same idea, but with `stream=True` enabled.
2929

3030
Plus these scripts to demonstrate additional features:
@@ -34,9 +34,9 @@ Plus these scripts to demonstrate additional features:
3434

3535
### Function calling
3636

37-
These scripts demonstrate using the Chat Completions API "tools" (a.k.a. function calling) feature, which lets the model decide when to call developer-defined functions and return structured arguments instead of (or before) a natural language answer.
37+
These scripts demonstrate using the Responses API "tools" (a.k.a. function calling) feature, which lets the model decide when to call developer-defined functions and return structured arguments instead of (or before) a natural language answer.
3838

39-
In all of these examples, a list of functions is declared in the `tools` parameter. The model may respond with `message.tool_calls` containing one or more tool calls. Each tool call includes the function `name` and a JSON string of `arguments` that match the declared schema. Your application is responsible for: (1) detecting tool calls, (2) executing the corresponding local / external logic, and (3) (optionally) sending the tool result back to the model for a final answer.
39+
In all of these examples, a list of functions is declared in the `tools` parameter. The model may respond with one or more tool calls as items in `response.output` (for example, items where `type == "function_call"`). Each tool call item includes the function `name` and a JSON string of `arguments` that match the declared schema. Your application is responsible for: (1) detecting tool calls, (2) executing the corresponding local / external logic, and (3) (optionally) sending the tool result back to the model for a final answer.
4040

4141
Scripts (in increasing order of capability):
4242

@@ -62,7 +62,7 @@ python -m pip install -r requirements-rag.txt
6262
Then run the scripts (in order of increasing complexity):
6363

6464
* [`rag_csv.py`](./rag_csv.py): Retrieves matching results from a CSV file and uses them to answer user's question.
65-
* [`rag_multiturn.py`](./rag_multiturn.py): The same idea, but with a back-and-forth chat interface using `input()` which keeps track of past messages and sends them with each chat completion call.
65+
* [`rag_multiturn.py`](./rag_multiturn.py): The same idea, but with a back-and-forth chat interface using `input()` which keeps track of past messages and sends them with each API call.
6666
* [`rag_queryrewrite.py`](./rag_queryrewrite.py): Adds a query rewriting step to the RAG process, where the user's question is rewritten to improve the retrieval results.
6767
* [`rag_documents_ingestion.py`](./rag_documents_ingestion.py): Ingests PDFs by using pymupdf to convert to markdown, then using Langchain to split into chunks, then using OpenAI to embed the chunks, and finally storing in a local JSON file.
6868
* [`rag_documents_flow.py`](./rag_documents_flow.py): A RAG flow that retrieves matching results from the local JSON file created by `rag_documents_ingestion.py`.

spanish/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Demos de Python con OpenAI
22

3-
Este repositorio contiene una colección de scripts en Python que demuestran cómo usar la API de OpenAI (y modelos compatibles) para generar completados de chat. 📺 [Video tutorial de como usar este repositorio](https://youtu.be/0WwpMFMHEOo?si=9K4jFdBYdj-kb_GL)
3+
Este repositorio contiene una colección de scripts en Python que demuestran cómo usar la API de Responses de OpenAI (y modelos compatibles). 📺 [Video tutorial de cómo usar este repositorio](https://youtu.be/0WwpMFMHEOo?si=9K4jFdBYdj-kb_GL)
44

55
* [Ejemplos](#ejemplos)
6-
* [Completados de chat de OpenAI](#completados-de-chat-de-openai)
6+
* [Responses de OpenAI](#responses-de-openai)
77
* [Llamadas a funciones (Function calling)](#llamadas-a-funciones-function-calling)
88
* [Generación aumentada con recuperación (RAG)](#generación-aumentada-con-recuperación-rag)
99
* [Salidas estructuradas](#salidas-estructuradas)
@@ -16,11 +16,11 @@ Este repositorio contiene una colección de scripts en Python que demuestran có
1616

1717
## Ejemplos
1818

19-
### Completados de chat de OpenAI
19+
### Responses de OpenAI
2020

21-
Estos scripts usan el paquete `openai` de Python para demostrar cómo utilizar la API de Chat Completions. En orden creciente de complejidad:
22-
1. [`chat.py`](chat.py): Script simple que muestra cómo generar un completado de chat.
23-
2. [`chat_stream.py`](chat_stream.py): Añade `stream=True` para recibir el completado progresivamente.
21+
Estos scripts usan el paquete `openai` de Python para demostrar cómo utilizar la API de Responses. En orden creciente de complejidad:
22+
1. [`chat.py`](chat.py): Script simple que muestra cómo generar una respuesta.
23+
2. [`chat_stream.py`](chat_stream.py): Añade `stream=True` para recibir la respuesta progresivamente.
2424
3. [`chat_history.py`](chat_history.py): Añade un chat bidireccional que conserva el historial y lo reenvía en cada llamada.
2525
4. [`chat_history_stream.py`](chat_history_stream.py): Igual que el anterior pero además con `stream=True`.
2626

@@ -32,9 +32,9 @@ Scripts adicionales de características:
3232

3333
### Llamadas a funciones (Function calling)
3434

35-
Estos scripts muestran cómo usar la característica "tools" (function calling) de la API de Chat Completions. Permite que el modelo decida si invoca funciones definidas por el desarrollador y devolver argumentos estructurados en lugar (o antes) de una respuesta en lenguaje natural.
35+
Estos scripts muestran cómo usar la característica "tools" (function calling) de la API de Responses. Permite que el modelo decida si invoca funciones definidas por el desarrollador y devolver argumentos estructurados en lugar (o antes) de una respuesta en lenguaje natural.
3636

37-
En todos los ejemplos se declara una lista de funciones en el parámetro `tools`. El modelo puede responder con `message.tool_calls` que contiene una o más llamadas. Cada llamada incluye el `name` de la función y una cadena JSON con `arguments` que respetan el esquema declarado. Tu aplicación debe: (1) detectar las llamadas, (2) ejecutar la lógica local/externa correspondiente y (3) (opcionalmente) enviar el resultado de la herramienta de vuelta al modelo para una respuesta final.
37+
En todos los ejemplos se declara una lista de funciones en el parámetro `tools`. En estos demos con Responses, las llamadas a herramientas aparecen en `response.output`, por ejemplo como elementos con `type == "function_call"`. Cada una de esas llamadas incluye el `name` de la función y una cadena JSON con `arguments` que respetan el esquema declarado. Tu aplicación debe: (1) detectar las llamadas, (2) ejecutar la lógica local/externa correspondiente y (3) (opcionalmente) enviar el resultado de la herramienta de vuelta al modelo para una respuesta final.
3838

3939
Scripts (en orden de capacidad):
4040

0 commit comments

Comments
 (0)