Skip to content

Commit

Permalink
Merge pull request #48 from DARPA-ASKEM/json-format
Browse files Browse the repository at this point in the history
Added response format param
  • Loading branch information
mwdchang authored Aug 30, 2024
2 parents 073170a + 361e2c8 commit d510b56
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gollm/openai/tool_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
from openai import OpenAI, AsyncOpenAI
from openai.types.chat.completion_create_params import ResponseFormat
from typing import List
from gollm.utils import (
exceeds_tokens,
Expand Down Expand Up @@ -152,7 +153,7 @@ def condense_chain(query: str, chunks: List[str], max_tokens: int = 16385) -> st
)
return output.choices[0].message.content

def generate_response(instruction: str) -> str:
def generate_response(instruction: str, response_format: ResponseFormat | None = None) -> str:
prompt = GENERAL_INSTRUCTION_PROMPT.format(instruction=instruction)
client = OpenAI()
output = client.chat.completions.create(
Expand All @@ -162,7 +163,8 @@ def generate_response(instruction: str) -> str:
presence_penalty=0,
temperature=0,
seed=123,
max_tokens=1024,
max_tokens=2048,
response_format=response_format,
messages=[
{"role": "user", "content": prompt},
],
Expand Down

0 comments on commit d510b56

Please sign in to comment.