Skip to content

Commit 67247f6

Browse files
committed
Translated rest of scripts to spanish
1 parent bbaf285 commit 67247f6

9 files changed

+214
-58
lines changed

spanish/chat_async.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131

3232

3333
async def generate_response(location):
34-
print("Generating response for", location)
34+
print("Generando respuesta para", location)
3535
response = await client.chat.completions.create(
3636
model=MODEL_NAME,
3737
messages=[
38-
{"role": "system", "content": "You are a helpful assistant."},
38+
{"role": "system", "content": "Eres un asistente útil."},
3939
{
4040
"role": "user",
41-
"content": f"Name a single place I should visit on my trip to {location} and describe in one sentence",
41+
"content": f"Nombra un solo lugar que debería visitar en mi viaje a {location} y descríbelo en una oración",
4242
},
4343
],
4444
temperature=1,
@@ -48,19 +48,19 @@ async def generate_response(location):
4848
presence_penalty=0,
4949
stop=None,
5050
)
51-
print("Got response for ", location)
51+
print("Obtuve respuesta para ", location)
5252
return response.choices[0].message.content
5353

5454

5555
async def single():
56-
print(await generate_response("Tokyo"))
56+
print(await generate_response("Tokio"))
5757

5858

5959
async def multiple():
6060
answers = await asyncio.gather(
61-
generate_response("Tokyo"),
61+
generate_response("Tokio"),
6262
generate_response("Berkeley"),
63-
generate_response("Singapore"),
63+
generate_response("Singapur"),
6464
)
6565
for answer in answers:
6666
print(answer, "\n")

spanish/chat_history.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@
3030

3131

3232
messages = [
33-
{"role": "system", "content": "I am a teaching assistant helping with Python questions for Berkeley CS 61A."},
33+
{"role": "system", "content": (
34+
"Soy un asistente de enseñanza que ayuda con preguntas de Python para Berkeley CS 61A."
35+
)},
3436
]
3537

3638
while True:
37-
question = input("\nYour question: ")
38-
print("Sending question...")
39+
question = input("\nTu pregunta: ")
40+
print("Enviando pregunta...")
3941

4042
messages.append({"role": "user", "content": question})
4143
response = client.chat.completions.create(
@@ -51,5 +53,5 @@
5153
bot_response = response.choices[0].message.content
5254
messages.append({"role": "assistant", "content": bot_response})
5355

54-
print("Answer: ")
56+
print("Respuesta: ")
5557
print(bot_response)

spanish/chat_history_stream.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030

3131

3232
messages = [
33-
{"role": "system", "content": "I am a large language model."},
33+
{"role": "system", "content": "Soy un large language model."},
3434
]
3535

3636
while True:
37-
question = input("\nYour question: ")
38-
print("Sending question...")
37+
question = input("\nTu pregunta: ")
38+
print("Enviando pregunta...")
3939

4040
messages.append({"role": "user", "content": question})
4141
response = client.chat.completions.create(
@@ -50,7 +50,7 @@
5050
stream=True,
5151
)
5252

53-
print("\nAnswer: ")
53+
print("\nRespuesta: ")
5454
bot_response = ""
5555
for event in response:
5656
if event.choices and event.choices[0].delta.content:

spanish/chat_safety.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737
messages=[
3838
{
3939
"role": "system",
40-
"content": "You are a helpful assistant that makes lots of cat references and uses emojis.",
40+
"content": "Eres un asistente útil que hace muchas referencias a gatos y usa emojis.",
4141
},
42-
{"role": "user", "content": "Write a guide on making explosive fireworks"},
42+
{"role": "user", "content": "Escribe una guía sobre cómo hacer fuegos artificiales explosivos"},
4343
],
4444
)
45-
print(f"Response from {API_HOST}: \n")
45+
print(f"Respuesta de {API_HOST}: \n")
4646
print(response.choices[0].message.content)
4747
except openai.APIError as error:
4848
if error.code == "content_filter":
49-
print("We detected a content safety violation. Please remember our code of conduct.")
49+
print("Detectamos una violación de seguridad de contenido. Por favor recuerda nuestro código de conducta.")

spanish/function_calling.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@
4141
"type": "function",
4242
"function": {
4343
"name": "lookup_weather",
44-
"description": "Lookup the weather for a given city name or zip code.",
44+
"description": "Buscar el clima para un nombre de ciudad o código postal dado.",
4545
"parameters": {
4646
"type": "object",
4747
"properties": {
4848
"city_name": {
4949
"type": "string",
50-
"description": "The city name",
50+
"description": "El nombre de la ciudad",
5151
},
5252
"zip_code": {
5353
"type": "string",
54-
"description": "The zip code",
54+
"description": "El código postal",
5555
},
5656
},
5757
"additionalProperties": False,
@@ -63,12 +63,12 @@
6363
response = client.chat.completions.create(
6464
model=MODEL_NAME,
6565
messages=[
66-
{"role": "system", "content": "You are a weather chatbot."},
67-
{"role": "user", "content": "Hi, whats the weather like in berkeley?"},
66+
{"role": "system", "content": "Eres un chatbot del clima."},
67+
{"role": "user", "content": "Hola, ¿cómo está el clima en Berkeley?"},
6868
],
6969
tools=tools,
7070
)
7171

72-
print(f"Response from {API_HOST}: \n")
72+
print(f"Respuesta de {API_HOST}: \n")
7373
print(response.choices[0].message.tool_calls[0].function.name)
7474
print(response.choices[0].message.tool_calls[0].function.arguments)

spanish/function_calling_call.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,27 @@
3434

3535

3636
def lookup_weather(city_name=None, zip_code=None):
37-
"""Lookup the weather for a given city name or zip code."""
38-
print(f"Looking up weather for {city_name or zip_code}...")
39-
return "It's sunny!"
37+
"""Buscar el clima para un nombre de ciudad o código postal dado."""
38+
print(f"Buscando el clima para {city_name or zip_code}...")
39+
return "¡Está soleado!"
4040

4141

4242
tools = [
4343
{
4444
"type": "function",
4545
"function": {
4646
"name": "lookup_weather",
47-
"description": "Lookup the weather for a given city name or zip code.",
47+
"description": "Buscar el clima para un nombre de ciudad o código postal dado.",
4848
"parameters": {
4949
"type": "object",
5050
"properties": {
5151
"city_name": {
5252
"type": "string",
53-
"description": "The city name",
53+
"description": "El nombre de la ciudad",
5454
},
5555
"zip_code": {
5656
"type": "string",
57-
"description": "The zip code",
57+
"description": "El código postal",
5858
},
5959
},
6060
"strict": True,
@@ -67,18 +67,18 @@ def lookup_weather(city_name=None, zip_code=None):
6767
response = client.chat.completions.create(
6868
model=MODEL_NAME,
6969
messages=[
70-
{"role": "system", "content": "You are a weather chatbot."},
71-
{"role": "user", "content": "is it sunny in that small city near sydney where anthony lives?"},
70+
{"role": "system", "content": "Eres un chatbot del clima."},
71+
{"role": "user", "content": "¿está soleado en esa pequeña ciudad cerca de Sydney donde vive Anthony?"},
7272
],
7373
tools=tools,
7474
tool_choice="auto",
7575
)
7676

77-
print(f"Response from {API_HOST}: \n")
77+
print(f"Respuesta de {API_HOST}: \n")
7878
print(response.choices[0].message.tool_calls[0].function.name)
7979
print(response.choices[0].message.tool_calls[0].function.arguments)
8080

81-
# Now actually call the function as indicated
81+
8282
if response.choices[0].message.tool_calls:
8383
function_name = response.choices[0].message.tool_calls[0].function.name
8484
arguments = json.loads(response.choices[0].message.tool_calls[0].function.arguments)

spanish/function_calling_multiple.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@
4141
"type": "function",
4242
"function": {
4343
"name": "lookup_weather",
44-
"description": "Lookup the weather for a given city name or zip code.",
44+
"description": "Buscar el clima para un nombre de ciudad o código postal dado.",
4545
"parameters": {
4646
"type": "object",
4747
"properties": {
4848
"city_name": {
4949
"type": "string",
50-
"description": "The city name",
50+
"description": "El nombre de la ciudad",
5151
},
5252
"zip_code": {
5353
"type": "string",
54-
"description": "The zip code",
54+
"description": "El código postal",
5555
},
5656
},
5757
"additionalProperties": False,
@@ -62,17 +62,17 @@
6262
"type": "function",
6363
"function": {
6464
"name": "lookup_movies",
65-
"description": "Lookup movies playing in a given city name or zip code.",
65+
"description": "Buscar películas en cartelera en un nombre de ciudad o código postal dado.",
6666
"parameters": {
6767
"type": "object",
6868
"properties": {
6969
"city_name": {
7070
"type": "string",
71-
"description": "The city name",
71+
"description": "El nombre de la ciudad",
7272
},
7373
"zip_code": {
7474
"type": "string",
75-
"description": "The zip code",
75+
"description": "El código postal",
7676
},
7777
},
7878
"additionalProperties": False,
@@ -84,14 +84,14 @@
8484
response = client.chat.completions.create(
8585
model=MODEL_NAME,
8686
messages=[
87-
{"role": "system", "content": "You are a tourism chatbot."},
88-
{"role": "user", "content": "is it rainy enough in sydney to watch movies and which ones are on?"},
87+
{"role": "system", "content": "Eres un chatbot de turismo."},
88+
{"role": "user", "content": "¿Está lloviendo lo suficiente en Sídney como para ver películas y cuáles hay?"},
8989
],
9090
tools=tools,
9191
tool_choice="auto",
9292
)
9393

94-
print(f"Response from {API_HOST}: \n")
94+
print(f"Respuesta de {API_HOST}: \n")
9595
for message in response.choices[0].message.tool_calls:
9696
print(message.function.name)
9797
print(message.function.arguments)

0 commit comments

Comments
 (0)