Skip to content

Commit

Permalink
👕 #91 mypyの以下のエラーを修正
Browse files Browse the repository at this point in the history
src/infrastructure/repository/openai/openai_cat_message_repository.py:142: error: Function is missing a return type annotation  [no-untyped-def]
  • Loading branch information
keitakn committed Jan 27, 2024
1 parent 4d78e4b commit 01d394e
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import json
from typing import AsyncGenerator, cast, List, TypedDict
from openai import AsyncOpenAI, AsyncStream
from openai.types.chat import ChatCompletionMessageParam, ChatCompletionChunk, ChatCompletionFunctionMessageParam
from openai.types.chat import (
ChatCompletionMessageParam,
ChatCompletionChunk,
ChatCompletionFunctionMessageParam,
)
from domain.repository.cat_message_repository_interface import (
CatMessageRepositoryInterface,
GenerateMessageForGuestUserDto,
Expand Down Expand Up @@ -79,7 +83,11 @@ async def generate_message_for_guest_user( # type: ignore

if chunk.choices[0].finish_reason == "function_call":
if function_info["name"] == "fetch_current_weather":
arguments = function_info["arguments"] if function_info["arguments"] is not None else ""
arguments = (
function_info["arguments"]
if function_info["arguments"] is not None
else ""
)
city_name = json.loads(arguments)["city_name"]
function_response = await self._fetch_current_weather(city_name)

Expand Down Expand Up @@ -140,7 +148,9 @@ async def _fetch_current_weather(
}

@staticmethod
async def _extract_chat_chunks(async_stream: AsyncStream[ChatCompletionChunk]):
async def _extract_chat_chunks(
async_stream: AsyncStream[ChatCompletionChunk],
) -> AsyncGenerator[GenerateMessageForGuestUserResult, None]:
ai_response_id = ""
async for chunk in async_stream:
chunk_message: str = (
Expand Down

0 comments on commit 01d394e

Please sign in to comment.