Spaces:
Runtime error
Runtime error
Merge pull request #30 from beautiful-code/til_v2
Browse files- endpoints.py +27 -11
endpoints.py
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
from dotenv import load_dotenv
|
| 2 |
load_dotenv()
|
| 3 |
|
| 4 |
-
from .workflows.courses.expectation_revision import ExpectationRevision, Inputs as ExpectationRevisionInputs, Response as ExpectationRevisionResponse
|
| 5 |
-
from .workflows.courses.suggest_check_question import SuggestCheckQuestion, Inputs as SuggestCheckQuestionInputs, Response as SuggestCheckQuestionResponse
|
| 6 |
-
from .workflows.courses.suggest_expectations import SuggestExpectations, Inputs as SuggestExpectationsInputs, Expectation, Response as SuggestExpectationsResponse
|
| 7 |
-
from .workflows.til.analyse_til import TilCrew, TilFeedbackResponse
|
| 8 |
-
from .workflows.til.analyse_til_v2 import AnalyseTilV2, TilV2FeedbackResponse
|
| 9 |
-
from .workflows.utils.feedback import Feedback, post_feedback
|
| 10 |
-
from fastapi import FastAPI, Query
|
| 11 |
-
from fastapi.middleware.cors import CORSMiddleware
|
| 12 |
-
from pydantic import UUID4
|
| 13 |
-
from tempenv import TemporaryEnvironment
|
| 14 |
-
from typing import List
|
| 15 |
import uvicorn
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
LANGSMITH_STAGING_PROJECT = "customer_agent"
|
|
@@ -108,6 +108,22 @@ async def staging_til_v2_feedback_kickoff(content: List[str]) -> TilV2FeedbackRe
|
|
| 108 |
return til_v2_logic(content)
|
| 109 |
|
| 110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
def course_learn_suggest_expectations_logic(inputs) -> SuggestExpectationsResponse:
|
| 112 |
print("Inputs: ", inputs)
|
| 113 |
result = SuggestExpectations().kickoff(inputs={
|
|
|
|
| 1 |
from dotenv import load_dotenv
|
| 2 |
load_dotenv()
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
import uvicorn
|
| 5 |
+
from typing import List
|
| 6 |
+
from tempenv import TemporaryEnvironment
|
| 7 |
+
from pydantic import UUID4
|
| 8 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 9 |
+
from fastapi import FastAPI, Query
|
| 10 |
+
from .workflows.utils.feedback import Feedback, post_feedback
|
| 11 |
+
from .workflows.til.analyse_til_v2 import AnalyseTilV2, TilV2FeedbackResponse
|
| 12 |
+
from .workflows.til.analyse_til import TilCrew, TilFeedbackResponse
|
| 13 |
+
from .workflows.courses.suggest_expectations import SuggestExpectations, Inputs as SuggestExpectationsInputs, Expectation, Response as SuggestExpectationsResponse
|
| 14 |
+
from .workflows.courses.suggest_check_question import SuggestCheckQuestion, Inputs as SuggestCheckQuestionInputs, Response as SuggestCheckQuestionResponse
|
| 15 |
+
from .workflows.courses.expectation_revision import ExpectationRevision, Inputs as ExpectationRevisionInputs, Response as ExpectationRevisionResponse
|
| 16 |
|
| 17 |
|
| 18 |
LANGSMITH_STAGING_PROJECT = "customer_agent"
|
|
|
|
| 108 |
return til_v2_logic(content)
|
| 109 |
|
| 110 |
|
| 111 |
+
@app.post("/v2/til_feedback/{run_id}/feedback", tags=["til_feedback"])
|
| 112 |
+
async def capture_feedback(run_id: UUID4, feedback: Feedback) -> str:
|
| 113 |
+
print("Metric Type: ", feedback.metric_type)
|
| 114 |
+
print("Feedback On: ", feedback.feedback_on)
|
| 115 |
+
post_feedback(run_id=run_id, feedback=feedback)
|
| 116 |
+
return "ok"
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
@app.post("/staging/v2/til_feedback/{run_id}/feedback", tags=["til_feedback", "staging"])
|
| 120 |
+
async def capture_feedback(run_id: UUID4, feedback: Feedback) -> str:
|
| 121 |
+
print("Metric Type: ", feedback.metric_type)
|
| 122 |
+
print("Feedback On: ", feedback.feedback_on)
|
| 123 |
+
post_feedback(run_id=run_id, feedback=feedback)
|
| 124 |
+
return "ok"
|
| 125 |
+
|
| 126 |
+
|
| 127 |
def course_learn_suggest_expectations_logic(inputs) -> SuggestExpectationsResponse:
|
| 128 |
print("Inputs: ", inputs)
|
| 129 |
result = SuggestExpectations().kickoff(inputs={
|