Skip to content

Commit e982229

Browse files
committed
change to ai.generate
1 parent 7600001 commit e982229

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

bigframes/operations/blob.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -804,35 +804,27 @@ def audio_transcribe(
804804
raise ValueError("Must specify the engine, supported value is 'bigquery'.")
805805

806806
import bigframes.bigquery as bbq
807-
import bigframes.ml.llm as llm
808807
import bigframes.pandas as bpd
809808

810809
# col name doesn't matter here. Rename to avoid column name conflicts
811810
audio_series = bigframes.series.Series(self._block)
812811

813812
prompt_text = "**Task:** Transcribe the provided audio. **Instructions:** - Your response must contain only the verbatim transcription of the audio. - Do not include any introductory text, summaries, or conversational filler in your response. The output should begin directly with the first word of the audio."
814813

815-
llm_model = llm.GeminiTextGenerator(
816-
model_name=model_name,
817-
session=self._block.session,
818-
connection_name=connection,
814+
# Use bbq.ai.generate() to transcribe audio
815+
transcribed_results = bbq.ai.generate(
816+
prompt=(prompt_text, audio_series),
817+
connection_id=connection,
818+
endpoint=model_name,
819+
request_type="unspecified",
819820
)
820821

821-
# transcribe audio using ML.GENERATE_TEXT
822-
transcribed_results = llm_model.predict(
823-
X=audio_series,
824-
prompt=[prompt_text, audio_series],
825-
temperature=0.0,
822+
transcribed_content_series = transcribed_results.struct.field("result").rename(
823+
"transcribed_content"
826824
)
827825

828-
transcribed_content_series = cast(
829-
bpd.Series, transcribed_results["ml_generate_text_llm_result"]
830-
).rename("transcribed_content")
831-
832826
if verbose:
833-
transcribed_status_series = cast(
834-
bpd.Series, transcribed_results["ml_generate_text_status"]
835-
)
827+
transcribed_status_series = transcribed_results.struct.field("status")
836828
results_df = bpd.DataFrame(
837829
{
838830
"status": transcribed_status_series,

tests/system/large/blob/test_function.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ def test_blob_transcribe(
424424
)
425425
.to_pandas()
426426
)
427+
print(actual)
427428

428429
# check relative length
429430
expected_text = "Now, as all books not primarily intended as picture-books consist principally of types composed to form letterpress"

0 commit comments

Comments
 (0)