Skip to content

new: langchain plugin #44

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

Merged
merged 2 commits into from
Aug 29, 2024
Merged

new: langchain plugin #44

merged 2 commits into from
Aug 29, 2024

Conversation

aMahanna
Copy link
Member

@aMahanna aMahanna commented Aug 27, 2024

Bringing back the LangChain plugin as an optional feature

# pip install nx-arangodb[llm]
import nx_arangodb as nxadb

G_adb = nxadb.Graph(name="Karate")

G_adb.chat("who is connected to node 1?")
G_adb.chat("who is connected to node 1?", verbose=True)
G_adb.chat("what is the shortest path from node 1 to node 34?")
G_adb.chat("update node 1 with property 'foo' set to 'bar'")

The default LLM used is GPT-4 via the ChatOpenAI class of the langchain_openai module, but users are free to pass their own model via the llm parameter to the chat() function.

@aMahanna aMahanna requested a review from hkernbach August 27, 2024 20:44
Comment on lines -374 to +387
# self._adj._fetch_all()
# TODO: what would this look like?

# NOTE: OUT OF SERVICE
# def chat(self, prompt: str) -> str:
# if self.__qa_chain is None:
# if not self.graph_exists_in_db:
# return "Could not initialize QA chain: Graph does not exist"
# def push(self) -> None:
# TODO: what would this look like?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about those two todos?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you share more information on those two methods. What are they for?

Copy link
Member Author

@aMahanna aMahanna Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya these are placeholders for a potential feature later on, completely unrelated to chat():

  • pull proposes the idea of fetching the "latest" state of an ArangoDB Graph, which would introduce the concept of cross-collaboration across the same ArangoDB Graph. I don't have an implementation in-mind yet, so it's purely hypothetical.

  • push would be more towards supporting transactions in an nxadb Graph. So something like this:

import nx_arangodb as nxadb

G = nxadb.Graph(name="MyGraph", use_transactions=True)

# Only modifies the cache:
G.nodes[1]['foo'] = 'bar'
G.add_node(2, foo='buz')
G.add_edge(1, 2)

G.push() # Sends the last 3 operations to the DB

Copy link
Member

@hkernbach hkernbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM to in general. Before we merge back, we need to discuss the two introduced TODOs.

@hkernbach hkernbach merged commit 9761c0d into main Aug 29, 2024
6 checks passed
@hkernbach hkernbach deleted the langchain-plugin branch August 29, 2024 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants