22
33import cmd
44import json
5- from typing import List , Tuple
5+ from typing import Any , Dict , List , Tuple
66
77import click
88
@@ -181,6 +181,12 @@ def interactive(
181181 "--frequency-penalty" , type = float , help = "Frequency penalty sampling method"
182182)
183183@click .option ("--min-p" , type = float , help = "Min p sampling" )
184+ @click .option (
185+ "--audio-url" ,
186+ type = str ,
187+ multiple = True ,
188+ help = "Audio URL to attach to the last user message" ,
189+ )
184190@click .option ("--no-stream" , is_flag = True , help = "Disable streaming" )
185191@click .option ("--logprobs" , type = int , help = "Return logprobs. Only works with --raw." )
186192@click .option ("--echo" , is_flag = True , help = "Echo prompt. Only works with --raw." )
@@ -200,6 +206,7 @@ def chat(
200206 presence_penalty : float | None = None ,
201207 frequency_penalty : float | None = None ,
202208 min_p : float | None = None ,
209+ audio_url : List [str ] | None = None ,
203210 no_stream : bool = False ,
204211 logprobs : int | None = None ,
205212 echo : bool | None = None ,
@@ -210,7 +217,22 @@ def chat(
210217 """Generate chat completions from messages"""
211218 client : Together = ctx .obj
212219
213- messages = [{"role" : msg [0 ], "content" : msg [1 ]} for msg in message ]
220+ messages : List [Dict [str , Any ]] = [
221+ {"role" : msg [0 ], "content" : msg [1 ]} for msg in message
222+ ]
223+
224+ if audio_url and messages :
225+ last_msg = messages [- 1 ]
226+ if last_msg ["role" ] == "user" :
227+ # Convert content to list if it is string
228+ if isinstance (last_msg ["content" ], str ):
229+ last_msg ["content" ] = [{"type" : "text" , "text" : last_msg ["content" ]}]
230+
231+ # Append audio URLs
232+ for url in audio_url :
233+ last_msg ["content" ].append (
234+ {"type" : "audio_url" , "audio_url" : {"url" : url }}
235+ )
214236
215237 response = client .chat .completions .create (
216238 model = model ,
0 commit comments