Skip to content

Commit

Permalink
Update llm.py (#8513)
Browse files Browse the repository at this point in the history
* Update llm.py

* Update llm.py

* Update llm.py

* Update llm.py

---------

Co-authored-by: Aarushi <[email protected]>
  • Loading branch information
ntindle and aarushik93 authored Oct 31, 2024
1 parent 3ea50f3 commit 74d8aa6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions autogpt_platform/backend/backend/blocks/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,18 +519,24 @@ def __init__(self):
test_mock={"llm_call": lambda *args, **kwargs: "Response text"},
)

def llm_call(self, input_data: AIStructuredResponseGeneratorBlock.Input) -> str:
def llm_call(
self,
input_data: AIStructuredResponseGeneratorBlock.Input,
credentials: APIKeyCredentials,
) -> str:
block = AIStructuredResponseGeneratorBlock()
response = block.run_once(input_data, "response")
response = block.run_once(input_data, "response", credentials=credentials)
self.merge_stats(block.execution_stats)
return response["response"]

def run(self, input_data: Input, **kwargs) -> BlockOutput:
def run(
self, input_data: Input, *, credentials: APIKeyCredentials, **kwargs
) -> BlockOutput:
object_input_data = AIStructuredResponseGeneratorBlock.Input(
**{attr: getattr(input_data, attr) for attr in input_data.model_fields},
expected_format={},
)
yield "response", self.llm_call(object_input_data)
yield "response", self.llm_call(object_input_data, credentials)


class SummaryStyle(Enum):
Expand Down

0 comments on commit 74d8aa6

Please sign in to comment.