Skip to content

Commit

Permalink
Removes append_exchange function
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonWeill committed Jan 5, 2024
1 parent 4397341 commit 5fe7667
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 17 deletions.
11 changes: 0 additions & 11 deletions packages/jupyter-ai-magics/jupyter_ai_magics/magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,6 @@ def handle_error(self, args: ErrorArgs):

return self.run_ai_cell(cell_args, prompt)

def _append_exchange_openai(self, prompt: str, output: str):
"""Appends a conversational exchange between user and an OpenAI Chat
model to a transcript that will be included in future exchanges."""
self.transcript_openai.append({"role": "user", "content": prompt})
self.transcript_openai.append({"role": "assistant", "content": output})

def _decompose_model_id(self, model_id: str):
"""Breaks down a model ID into a two-tuple (provider_id, local_model_id). Returns (None, None) if indeterminate."""
# custom_model_registry maps keys to either a model name (a string) or an LLMChain.
Expand Down Expand Up @@ -559,11 +553,6 @@ def run_ai_cell(self, args: CellArgs, prompt: str):
result = provider.generate([prompt])

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

# if openai-chat, append exchange to transcript
if provider_id == "openai-chat":
self._append_exchange_openai(prompt, output)

md = {"jupyter_ai": {"provider_id": provider_id, "model_id": local_model_id}}

return self.display_output(output, args.format, md)
Expand Down
6 changes: 0 additions & 6 deletions packages/jupyter-ai-magics/jupyter_ai_magics/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,12 +561,6 @@ class ChatOpenAIProvider(BaseProvider, ChatOpenAI):
pypi_package_deps = ["openai"]
auth_strategy = EnvAuthStrategy(name="OPENAI_API_KEY")

def append_exchange(self, prompt: str, output: str):
"""Appends a conversational exchange between user and an OpenAI Chat
model to a transcript that will be included in future exchanges."""
self.messages.append({"role": "user", "content": prompt})
self.messages.append({"role": "assistant", "content": output})

fields = [
TextField(
key="openai_api_base", label="Base API URL (optional)", format="text"
Expand Down

0 comments on commit 5fe7667

Please sign in to comment.