Skip to content

Commit e22abde

Browse files
amullick-gitAmarnath Mullick
andauthored
feat: Add Spanner Graph QA Chain (googleapis#111)
* Add Spanner Graph QA Chain * Formatted notebook. Added copyright message to prompts file. * Add missing imports for random graph name * Make input table name randomized in integration tests to avoid name collision for tests running parallely from different python environments * Provide timeout to graph cleanup * Make default timeout of 300 secs for ddl application * Increase timeout of integration test * Change integration test timeout * Minor formatting fixes * Make the ddl operations test fixture scoped for the module * Addressed review comments * Addressed a few other review comments. * Remove unused function * fix type check errors * Addressed review comments * Addressed review comments --------- Co-authored-by: Amarnath Mullick <[email protected]>
1 parent 28c0add commit e22abde

File tree

10 files changed

+1578
-5
lines changed

10 files changed

+1578
-5
lines changed

README.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,34 @@ See the full `Spanner Graph Store`_ tutorial.
151151

152152
.. _`Spanner Graph Store`: https://github.com/googleapis/langchain-google-spanner-python/blob/main/docs/graph_store.ipynb
153153

154+
Spanner Graph QA Chain Usage
155+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
156+
157+
Use ``SpannerGraphQAChain`` for question answering over a graph stored in Spanner Graph.
158+
159+
.. code:: python
160+
161+
from langchain_google_spanner import SpannerGraphStore, SpannerGraphQAChain
162+
from langchain_google_vertexai import ChatVertexAI
163+
164+
165+
graph = SpannerGraphStore(
166+
instance_id="my-instance",
167+
database_id="my-database",
168+
graph_name="my_graph",
169+
)
170+
llm = ChatVertexAI()
171+
chain = SpannerGraphQAChain.from_llm(
172+
llm,
173+
graph=graph,
174+
allow_dangerous_requests=True
175+
)
176+
chain.invoke("query=Where does Sarah's sibling live?")
177+
178+
See the full `Spanner Graph QA Chain`_ tutorial.
179+
180+
.. _`Spanner Graph QA Chain`: https://github.com/googleapis/langchain-google-spanner-python/blob/main/docs/graph_qa_chain.ipynb
181+
154182

155183
Contributions
156184
~~~~~~~~~~~~~

0 commit comments

Comments
 (0)