File size: 1,585 Bytes
d9e3edb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from crewai import Crew, Process

from agents_rag.agents import rag_agent, writer_rag
from agents_rag.tasks import rag_task, write_rag_task


def get_crew_response(query=None, context=None, url=None):
    if url != "None":
        print("in crwe url")
        ## Forming the tech focused crew with some enhanced configuration
        crew_search = Crew(
            agents=[writer_rag],
            tasks=[write_rag_task],
            process=Process.sequential,
        )

        ## starting the task execution process wiht enhanced feedback
        result_web = crew_search.kickoff(
            inputs={
                "query": f"{query}",
                "url": f"{url}",
            }
        )
        print(result_web)

        result_web = result_web.removeprefix("```json")
        result_web = result_web.removesuffix("```")
        result_web = result_web.replace("```", "")

        return result_web
    else:
        print("In crew else")
        ## Forming the tech focused crew with some enhanced configuration
        crew_rag = Crew(
            agents=[rag_agent],
            tasks=[rag_task],
            process=Process.sequential,
        )

        ## starting the task execution process wiht enhanced feedback
        result_rag = crew_rag.kickoff(
            inputs={
                "query": f"{query}",
                "context": f"{context}",
            }
        )

        result_rag = result_rag.removeprefix("```json")
        result_rag = result_rag.removesuffix("```")
        result_rag = result_rag.replace("```", "")

        return result_rag