|
31 | 31 |
|
32 | 32 |
|
33 | 33 | # TODO: Add docstrings and type hints |
34 | | -<<<<<<< HEAD |
35 | 34 | def anthropic_citations(client, user_prompt, content_chunks): |
36 | | -======= |
37 | | -def anthropic_citations(client, content_chunks, user_prompt): |
38 | | ->>>>>>> listOfMed |
39 | 35 | """ |
40 | 36 | """ |
41 | 37 |
|
@@ -90,45 +86,16 @@ class RuleExtractionAPIView(APIView): |
90 | 86 | def get(self, request): |
91 | 87 | try: |
92 | 88 |
|
93 | | -<<<<<<< HEAD |
94 | 89 | client = anthropic.Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY")) |
95 | 90 |
|
96 | | -======= |
97 | | - client = anthropic.Anthropic( |
98 | | - api_key=os.getenv("ANTHROPIC_API_KEY")) |
99 | | - |
100 | | - user_prompt = """ |
101 | | - I'm creating a system to analyze medical research. It processes peer-reviewed papers to extract key details |
102 | | -
|
103 | | - Act as a seasoned physician or medical professional who treat patients with bipolar disorder |
104 | | -
|
105 | | - Identify rules for medication inclusion or exclusion based on medical history or concerns |
106 | | -
|
107 | | - Return an output with the same structure as these examples: |
108 | | -
|
109 | | - The rule is history of suicide attempts. The type of rule is "INCLUDE". The reason is lithium is the |
110 | | - only medication on the market that has been proven to reduce suicidality in patients with bipolar disorder. |
111 | | - The medications for this rule are lithium. |
112 | | -
|
113 | | - The rule is weight gain concerns. The type of rule is "EXCLUDE". The reason is Seroquel, Risperdal, Abilify, and |
114 | | - Zyprexa are known for causing weight gain. The medications for this rule are Quetiapine, Aripiprazole, Olanzapine, Risperidone |
115 | | - } |
116 | | - """ |
117 | | - |
118 | | ->>>>>>> listOfMed |
119 | 91 | guid = request.query_params.get('guid') |
120 | 92 |
|
121 | 93 | query = Embeddings.objects.filter(upload_file__guid=guid) |
122 | 94 |
|
123 | 95 | chunks = [{"type": "text", "text": chunk.text} for chunk in query] |
124 | 96 |
|
125 | | -<<<<<<< HEAD |
126 | 97 | texts, cited_texts = anthropic_citations(client, USER_PROMPT, chunks) |
127 | 98 |
|
128 | | -======= |
129 | | - texts, cited_texts = anthropic_citations( |
130 | | - client, chunks, user_prompt) |
131 | | ->>>>>>> listOfMed |
132 | 99 |
|
133 | 100 | return Response({"texts": texts, "cited_texts": cited_texts}, status=status.HTTP_200_OK) |
134 | 101 |
|
|
0 commit comments