-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(feat): resolve merge conflicts
- Loading branch information
Showing
11 changed files
with
349 additions
and
5 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,74 @@ | ||
amqp==5.2.0 | ||
annotated-types==0.7.0 | ||
anyio==4.4.0 | ||
asgiref==3.8.1 | ||
attrs==24.1.0 | ||
beautifulsoup4==4.12.3 | ||
billiard==4.2.0 | ||
bs4==0.0.2 | ||
celery==5.4.0 | ||
certifi==2024.7.4 | ||
cffi==1.17.0 | ||
charset-normalizer==3.3.2 | ||
click==8.1.7 | ||
click-didyoumean==0.3.1 | ||
click-plugins==1.1.1 | ||
click-repl==0.3.0 | ||
cron-descriptor==1.4.3 | ||
cryptography==43.0.0 | ||
distro==1.9.0 | ||
Django==5.0.8 | ||
django-admin-interface==0.28.8 | ||
django-celery-beat==2.6.0 | ||
django-ckeditor==6.7.1 | ||
django-ckeditor-5==0.2.13 | ||
django-colorfield==0.11.0 | ||
django-cors-headers==4.4.0 | ||
django-filter==24.2 | ||
django-jazzmin==3.0.0 | ||
django-js-asset==2.2.0 | ||
django-shortcuts==1.6 | ||
django-sortedm2m==4.0.0 | ||
django-timezone-field==7.0 | ||
django-tinymce==4.1.0 | ||
djangorestframework==3.15.2 | ||
drf-spectacular==0.27.2 | ||
h11==0.14.0 | ||
httpcore==1.0.5 | ||
httpx==0.27.0 | ||
idna==3.7 | ||
inflection==0.5.1 | ||
jiter==0.8.2 | ||
jsonschema==4.23.0 | ||
jsonschema-specifications==2023.12.1 | ||
kombu==5.4.0 | ||
openai==1.57.2 | ||
pillow==10.4.0 | ||
prompt_toolkit==3.0.47 | ||
pycparser==2.22 | ||
pydantic==2.10.3 | ||
pydantic_core==2.27.1 | ||
pyOpenSSL==24.2.1 | ||
python-crontab==3.2.0 | ||
python-dateutil==2.9.0.post0 | ||
python-decouple==3.8 | ||
python-dotenv==1.0.1 | ||
python-slugify==8.0.4 | ||
PyYAML==6.0.1 | ||
redis==5.0.8 | ||
referencing==0.35.1 | ||
requests==2.32.3 | ||
rpds-py==0.19.1 | ||
six==1.16.0 | ||
sniffio==1.3.1 | ||
soupsieve==2.6 | ||
sqlparse==0.5.1 | ||
text-unidecode==1.3 | ||
tqdm==4.67.1 | ||
typing_extensions==4.12.2 | ||
tzdata==2024.1 | ||
uritemplate==4.1.1 | ||
urllib3==2.2.2 | ||
vine==5.1.0 | ||
wcwidth==0.2.13 | ||
whitenoise==6.7.0 |
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
18 changes: 18 additions & 0 deletions
18
server/apps/research/migrations/0017_article_gpt_summary_alter_article_summary.py
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,18 @@ | ||
# Generated by Django 5.0.8 on 2024-12-10 18:18 | ||
|
||
import tinymce.models | ||
from django.db import migrations | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('research', '0016_article_related_articles'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='article', | ||
name='gpt_summary', | ||
field=tinymce.models.HTMLField(blank=True, null=True), | ||
), | ||
] |
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
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
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,4 @@ | ||
""" | ||
Services package for the research app. | ||
This package contains service classes that handle business logic and external API interactions. | ||
""" |
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,42 @@ | ||
from django.conf import settings | ||
from openai import AsyncOpenAI | ||
|
||
class GPTService: | ||
"""Service for handling OpenAI GPT API interactions.""" | ||
|
||
def __init__(self): | ||
self.client = AsyncOpenAI(api_key=settings.OPENAI_API_KEY) | ||
self.model = "gpt-3.5-turbo" | ||
self.max_tokens = 500 | ||
|
||
async def prompt(self, system: str, user: str) -> str: | ||
""" | ||
Send a prompt to GPT and get the response. | ||
Args: | ||
system (str): The system message that sets the behavior of the assistant | ||
user (str): The user's input/question | ||
Returns: | ||
str: The generated response from GPT | ||
Raises: | ||
Exception: If there's an error in the API call or if the API key is not set | ||
""" | ||
if not settings.OPENAI_API_KEY: | ||
raise Exception("OpenAI API key is not configured") | ||
|
||
try: | ||
completion = await self.client.chat.completions.create( | ||
model=self.model, | ||
messages=[ | ||
{"role": "system", "content": system}, | ||
{"role": "user", "content": user} | ||
], | ||
max_tokens=self.max_tokens | ||
) | ||
# Access the response content directly from the completion object | ||
return completion.choices[0].message.content | ||
except Exception as e: | ||
print(e) | ||
raise Exception(f"Error calling OpenAI API: {str(e)}") |
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
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
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,28 @@ | ||
.generate-summary-btn { | ||
background-color: #0C4B33; | ||
color: white; | ||
padding: 10px 15px; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
font-weight: bold; | ||
margin-left: 10px; | ||
align-self: baseline; | ||
} | ||
|
||
.generate-summary-btn:disabled { | ||
background-color: #cccccc; | ||
cursor: not-allowed; | ||
} | ||
|
||
.summary-status { | ||
margin-left: 10px; | ||
font-style: italic; | ||
color: #666; | ||
} | ||
|
||
.generate-summary-container-btn { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 10px; | ||
} |
Oops, something went wrong.