-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import boto3 | ||
from langchain_aws import ChatBedrock | ||
client=boto3.client(service_name="bedrock-runtime",region_name="us-east-1") | ||
llm=ChatBedrock(model_id="amazon.titan-text-premier-v1:0",client=client) | ||
response=llm.invoke("write an articvle on AI in Education sector") | ||
print(response.content) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from fastapi import FastAPI, HTTPException | ||
from pydantic import BaseModel | ||
from neo4j import GraphDatabase | ||
|
||
app = FastAPI() | ||
|
||
# Neo4j driver initialization | ||
uri = "bolt://localhost:7687" # Change to your Neo4j URI | ||
user = "neo4j" # Change to your Neo4j username | ||
password = "12345678" # Change to your Neo4j password | ||
driver = GraphDatabase.driver(uri, auth=(user, password)) | ||
|
||
class Node(BaseModel): | ||
label: str | ||
properties: dict | ||
|
||
def create_node_in_neo4j(label: str, properties: dict): | ||
query = f"CREATE (n:{label}) set n= $properties RETURN n" | ||
with driver.session() as session: | ||
x={"properties":properties} | ||
result = session.run(query, x) | ||
return result.single() | ||
|
||
@app.post("/nodes/") | ||
async def create_node(node: Node): | ||
try: | ||
result = create_node_in_neo4j(node.label, node.properties) | ||
if result: | ||
return {"message": "Node created successfully", "node": result["n"]} | ||
else: | ||
raise HTTPException(status_code=400, detail="Node creation failed") | ||
except Exception as e: | ||
raise HTTPException(status_code=500, detail=str(e)) | ||
|
||
if __name__ == "__main__": | ||
import uvicorn | ||
uvicorn.run(app, host="0.0.0.0", port=8000) |