Resolve some of the PR comments
This commit is contained in:
parent
99ebfb3113
commit
c9bfe1752d
12 changed files with 28 additions and 43 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
from cognito.JWTBearer import JWKS, JWTBearer, JWTAuthorizationCredentials
|
from cognito.JWTBearer import JWKS, JWTBearer, JWTAuthorizationCredentials
|
||||||
|
import os
|
||||||
|
import boto3
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
region = "eu-west-1"
|
region = "eu-west-1"
|
||||||
|
|
@ -13,17 +14,14 @@ print(jwks)
|
||||||
|
|
||||||
auth = JWTBearer(jwks)
|
auth = JWTBearer(jwks)
|
||||||
|
|
||||||
|
|
||||||
import requests
|
|
||||||
|
|
||||||
# Set the Cognito authentication endpoint URL
|
# Set the Cognito authentication endpoint URL
|
||||||
|
|
||||||
auth = JWTBearer(jwks)
|
auth = JWTBearer(jwks)
|
||||||
|
|
||||||
# Set the user credentials
|
# Set the user credentials
|
||||||
|
|
||||||
username = "" #needed
|
username = os.getenv("COGNITO_USERNAME")
|
||||||
password = "" #needed
|
password = os.getenv("COGNITO_PASSWORD")
|
||||||
|
|
||||||
# Create the authentication payload
|
# Create the authentication payload
|
||||||
payload = {
|
payload = {
|
||||||
|
|
@ -36,10 +34,10 @@ payload = {
|
||||||
token_endpoint = f"https://your-cognito-domain.auth.{region}.amazoncognito.com/oauth2/token"
|
token_endpoint = f"https://your-cognito-domain.auth.{region}.amazoncognito.com/oauth2/token"
|
||||||
|
|
||||||
# Set the client credentials
|
# Set the client credentials
|
||||||
client_id = "" #needed
|
client_id = os.getenv("AWS_CLIENT_ID")
|
||||||
client_secret = ""
|
client_secret = os.getenv("AWS_CLIENT_SECRET")
|
||||||
|
|
||||||
|
|
||||||
import boto3
|
|
||||||
def authenticate_and_get_token(username: str, password: str,
|
def authenticate_and_get_token(username: str, password: str,
|
||||||
user_pool_id: str, app_client_id: str) -> None:
|
user_pool_id: str, app_client_id: str) -> None:
|
||||||
client = boto3.client('cognito-idp')
|
client = boto3.client('cognito-idp')
|
||||||
|
|
@ -55,8 +53,8 @@ def authenticate_and_get_token(username: str, password: str,
|
||||||
)
|
)
|
||||||
|
|
||||||
print("Log in success")
|
print("Log in success")
|
||||||
print("Access token:", resp['AuthenticationResult']['AccessToken'])
|
# print("Access token:", resp['AuthenticationResult']['AccessToken'])
|
||||||
print("ID token:", resp['AuthenticationResult']['IdToken'])
|
# print("ID token:", resp['AuthenticationResult']['IdToken'])
|
||||||
|
|
||||||
|
|
||||||
authenticate_and_get_token(username, password, user_pool_id, client_id)
|
authenticate_and_get_token(username, password, user_pool_id, client_id)
|
||||||
|
|
@ -1,17 +1,8 @@
|
||||||
|
|
||||||
# Make sure to install the following packages: dlt, langchain, duckdb, python-dotenv, openai, weaviate-client
|
|
||||||
import json
|
|
||||||
from typing import Any
|
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
import marvin
|
|
||||||
from deep_translator import GoogleTranslator
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from langchain.agents import initialize_agent, AgentType
|
|
||||||
from langchain.output_parsers import PydanticOutputParser
|
|
||||||
from langchain.tools import tool
|
|
||||||
from pydantic import parse_obj_as
|
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
from langchain import OpenAI
|
from langchain import OpenAI
|
||||||
|
|
@ -23,16 +14,10 @@ import tracemalloc
|
||||||
tracemalloc.start()
|
tracemalloc.start()
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
|
||||||
from langchain import PromptTemplate
|
|
||||||
from langchain.chains.openai_functions import create_structured_output_chain
|
|
||||||
from langchain.prompts import HumanMessagePromptTemplate, ChatPromptTemplate
|
|
||||||
from pydantic import BaseModel, Field
|
|
||||||
from dotenv import load_dotenv
|
|
||||||
from langchain.schema import SystemMessage, HumanMessage
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
load_dotenv()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
|
|
||||||
# Make sure to install the following packages: dlt, langchain, duckdb, python-dotenv, openai, weaviate-client
|
|
||||||
import json
|
import json
|
||||||
from typing import Any
|
from typing import Any
|
||||||
import logging
|
import logging
|
||||||
|
|
@ -7,13 +6,12 @@ import logging
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
import marvin
|
import marvin
|
||||||
from deep_translator import GoogleTranslator
|
from deep_translator import GoogleTranslator
|
||||||
from dotenv import load_dotenv
|
|
||||||
from langchain.agents import initialize_agent, AgentType
|
from langchain.agents import initialize_agent, AgentType
|
||||||
from langchain.output_parsers import PydanticOutputParser
|
from langchain.output_parsers import PydanticOutputParser
|
||||||
from langchain.tools import tool
|
from langchain.tools import tool
|
||||||
from pydantic import parse_obj_as
|
from pydantic import parse_obj_as
|
||||||
|
|
||||||
load_dotenv()
|
|
||||||
from langchain import OpenAI
|
from langchain import OpenAI
|
||||||
from langchain.chat_models import ChatOpenAI
|
from langchain.chat_models import ChatOpenAI
|
||||||
from typing import Optional, Dict, List, Union
|
from typing import Optional, Dict, List, Union
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class MemoryModel(Base):
|
||||||
id = Column(String, primary_key=True)
|
id = Column(String, primary_key=True)
|
||||||
user_id = Column(String, ForeignKey('users.id'), index=True)
|
user_id = Column(String, ForeignKey('users.id'), index=True)
|
||||||
created_at = Column(DateTime, default=datetime.utcnow)
|
created_at = Column(DateTime, default=datetime.utcnow)
|
||||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
updated_at = Column(DateTime, onupdate=datetime.utcnow)
|
||||||
methods_list = Column(String , nullable=True)
|
methods_list = Column(String , nullable=True)
|
||||||
attributes_list = Column(String, nullable=True)
|
attributes_list = Column(String, nullable=True)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class MetaDatas(Base):
|
||||||
contract_metadata = Column(String, nullable=False)
|
contract_metadata = Column(String, nullable=False)
|
||||||
memory_id = Column(String, ForeignKey('memories.id'), index=True)
|
memory_id = Column(String, ForeignKey('memories.id'), index=True)
|
||||||
created_at = Column(DateTime, default=datetime.utcnow)
|
created_at = Column(DateTime, default=datetime.utcnow)
|
||||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
updated_at = Column(DateTime, onupdate=datetime.utcnow)
|
||||||
|
|
||||||
user = relationship("User", back_populates="metadatas")
|
user = relationship("User", back_populates="metadatas")
|
||||||
memory = relationship("MemoryModel", back_populates="metadatas")
|
memory = relationship("MemoryModel", back_populates="metadatas")
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class Operation(Base):
|
||||||
id = Column(String, primary_key=True)
|
id = Column(String, primary_key=True)
|
||||||
session_id = Column(String, ForeignKey('sessions.id'), index=True)
|
session_id = Column(String, ForeignKey('sessions.id'), index=True)
|
||||||
created_at = Column(DateTime, default=datetime.utcnow)
|
created_at = Column(DateTime, default=datetime.utcnow)
|
||||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
updated_at = Column(DateTime, onupdate=datetime.utcnow)
|
||||||
|
|
||||||
session = relationship("Session", back_populates="operations")
|
session = relationship("Session", back_populates="operations")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class Session(Base):
|
||||||
id = Column(String, primary_key=True)
|
id = Column(String, primary_key=True)
|
||||||
user_id = Column(String, ForeignKey('users.id'), index=True)
|
user_id = Column(String, ForeignKey('users.id'), index=True)
|
||||||
created_at = Column(DateTime, default=datetime.utcnow)
|
created_at = Column(DateTime, default=datetime.utcnow)
|
||||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
updated_at = Column(DateTime, onupdate=datetime.utcnow)
|
||||||
|
|
||||||
user = relationship("User", back_populates="sessions")
|
user = relationship("User", back_populates="sessions")
|
||||||
operations = relationship("Operation", back_populates="session", cascade="all, delete-orphan")
|
operations = relationship("Operation", back_populates="session", cascade="all, delete-orphan")
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class TestOutput(Base):
|
||||||
id = Column(String, primary_key=True)
|
id = Column(String, primary_key=True)
|
||||||
test_set_id = Column(String, ForeignKey('test_sets.id'), index=True)
|
test_set_id = Column(String, ForeignKey('test_sets.id'), index=True)
|
||||||
created_at = Column(DateTime, default=datetime.utcnow)
|
created_at = Column(DateTime, default=datetime.utcnow)
|
||||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
updated_at = Column(DateTime, onupdate=datetime.utcnow)
|
||||||
|
|
||||||
test_set = relationship("TestSet", back_populates="test_outputs")
|
test_set = relationship("TestSet", back_populates="test_outputs")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class TestSet(Base):
|
||||||
id = Column(String, primary_key=True)
|
id = Column(String, primary_key=True)
|
||||||
user_id = Column(String, ForeignKey('users.id'), index=True)
|
user_id = Column(String, ForeignKey('users.id'), index=True)
|
||||||
created_at = Column(DateTime, default=datetime.utcnow)
|
created_at = Column(DateTime, default=datetime.utcnow)
|
||||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
updated_at = Column(DateTime, onupdate=datetime.utcnow)
|
||||||
|
|
||||||
user = relationship("User", back_populates="test_sets")
|
user = relationship("User", back_populates="test_sets")
|
||||||
test_outputs = relationship("TestOutput", back_populates="test_set", cascade="all, delete-orphan")
|
test_outputs = relationship("TestOutput", back_populates="test_set", cascade="all, delete-orphan")
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class User(Base):
|
||||||
id = Column(String, primary_key=True)
|
id = Column(String, primary_key=True)
|
||||||
name = Column(String, nullable=False, unique=True, index=True)
|
name = Column(String, nullable=False, unique=True, index=True)
|
||||||
created_at = Column(DateTime, default=datetime.utcnow)
|
created_at = Column(DateTime, default=datetime.utcnow)
|
||||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
updated_at = Column(DateTime, onupdate=datetime.utcnow)
|
||||||
|
|
||||||
memories = relationship("MemoryModel", back_populates="user", cascade="all, delete-orphan")
|
memories = relationship("MemoryModel", back_populates="user", cascade="all, delete-orphan")
|
||||||
sessions = relationship("Session", back_populates="user", cascade="all, delete-orphan")
|
sessions = relationship("Session", back_populates="user", cascade="all, delete-orphan")
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,13 @@ from deepeval.metrics.overall_score import assert_overall_score
|
||||||
import json
|
import json
|
||||||
from deepeval.metrics.overall_score import OverallScoreMetric
|
from deepeval.metrics.overall_score import OverallScoreMetric
|
||||||
|
|
||||||
# Write a sample ChatGPT function
|
# Needs to pass a QA test set
|
||||||
|
|
||||||
|
# Needs to separately fetch QA test set from DB
|
||||||
|
|
||||||
|
# Needs to have a function to run the tests that contain test set and store results in the DB
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
|
|
|
||||||
|
|
@ -27,17 +27,15 @@ import tracemalloc
|
||||||
|
|
||||||
tracemalloc.start()
|
tracemalloc.start()
|
||||||
|
|
||||||
import os
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from langchain.embeddings.openai import OpenAIEmbeddings
|
from langchain.embeddings.openai import OpenAIEmbeddings
|
||||||
from dotenv import load_dotenv
|
|
||||||
from langchain.schema import Document
|
from langchain.schema import Document
|
||||||
import uuid
|
import uuid
|
||||||
import weaviate
|
import weaviate
|
||||||
from marshmallow import Schema, fields
|
from marshmallow import Schema, fields
|
||||||
import json
|
import json
|
||||||
|
|
||||||
load_dotenv()
|
|
||||||
|
|
||||||
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY", "")
|
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY", "")
|
||||||
marvin.settings.openai.api_key = os.environ.get("OPENAI_API_KEY")
|
marvin.settings.openai.api_key = os.environ.get("OPENAI_API_KEY")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue