Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed case where usermessage is none #50

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions copilot/messages_builder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from copilot.context import Context
from copilot.conversation import Conversation
from copilot.sample_conversations import unix_fish_sample_conversations
from copilot.sample_conversations import unix_bourne_sample_conversations, windows_cmd_sample_conversations
from copilot.sample_conversations import (
unix_bourne_sample_conversations,
windows_cmd_sample_conversations,
)
from typing import Optional


def user_message(context: Context):
Expand Down Expand Up @@ -62,13 +66,12 @@ def system_messages(context: Context) -> list:
return messages


def build_conversation(context: Context, usermessage: str) -> Conversation:
def build_conversation(
context: Context, usermessage: Optional[str] = None
) -> Conversation:
messages = []
messages.extend(system_messages(context))
if not usermessage:
usermessage = user_message(context)
messages.append({"role": "user", "content": usermessage})
return Conversation(
messages=messages,
model=context.model
)
return Conversation(messages=messages, model=context.model)