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

Backport PR #1075 on branch v3-dev (Fix magic commands when using non-chat providers w/ history) #1080

Merged
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
22 changes: 12 additions & 10 deletions packages/jupyter-ai-magics/jupyter_ai_magics/magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,17 +603,19 @@ def run_ai_cell(self, args: CellArgs, prompt: str):
else:
# generate output from model via provider
if context:
inputs = [
(
f"AI: {message.content}"
if message.type == "ai"
else f"{message.type.title()}: {message.content}"
)
for message in context + [HumanMessage(content=prompt)]
]
inputs = "\n\n".join(
[
(
f"AI: {message.content}"
if message.type == "ai"
else f"{message.type.title()}: {message.content}"
)
for message in context + [HumanMessage(content=prompt)]
]
)
else:
inputs = [prompt]
result = provider.generate(inputs)
inputs = prompt
result = provider.generate([inputs])

output = result.generations[0][0].text

Expand Down
Loading