Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,17 @@ def ia_researcher_assistance_endpoint():
return jsonify({"status": "success", "message": message})


@app.route('/api/v1/nlp/assistance', methods=['POST'])
@require_api_key
def nlp_assistance_endpoint():
data = request.get_json()
prompt = data.get('prompt')
if not prompt:
return jsonify({"error": _("Prompt is required")}), 400
message = google_ai.provide_nlp_assistance(prompt)
return jsonify({"status": "success", "message": message})


@app.route('/api/v1/translate', methods=['POST'])
@require_api_key
def translate_endpoint():
Expand Down
38 changes: 38 additions & 0 deletions frontend/static/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,44 @@ document.addEventListener('DOMContentLoaded', () => {
});
}

// --- NLP Specialist Assistance ---
const nlpBtn = document.getElementById('nlp-btn');
if (nlpBtn) {
nlpBtn.addEventListener('click', async () => {
const input = document.getElementById('nlp-input');
const responseContainer = document.getElementById('nlp-response');
const apiKey = getApiKey("Please enter your API key to use the NLP Specialist:");

if (!apiKey) {
responseContainer.textContent = 'API key is required.';
return;
}

try {
const response = await fetch('/api/v1/nlp/assistance', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': apiKey
},
body: JSON.stringify({
prompt: input.value
})
});

if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'Failed to get a response from the NLP specialist');
}

const result = await response.json();
responseContainer.textContent = result.message;
} catch (error) {
responseContainer.textContent = `Error: ${error.message}`;
}
});
}

// --- IA Researcher Assistance ---
const iaResearcherBtn = document.getElementById('ia-researcher-btn');
if (iaResearcherBtn) {
Expand Down
17 changes: 17 additions & 0 deletions frontend/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<div class="logo">UsingAI</div>
<ul>
<li><a href="#services">Services</a></li>
<li><a href="#nlp-assistance">NLP</a></li>
<li><a href="#fake-content-verification">Verification</a></li>
<li><a href="#military-assistance">Military</a></li>
<li><a href="#purchase">Purchase</a></li>
Expand Down Expand Up @@ -224,6 +225,22 @@ <h3>{{ _('AI Research Support') }}</h3>
</div>
</section>

<!-- NLP Specialist Section -->
<section id="nlp-assistance" class="services">
<h2>{{ _('NLP Specialist') }}</h2>
<div class="service-cards">
<div class="card">
<h3>{{ _('Natural Language Processing Support') }}</h3>
<p>{{ _('Enter your request for NLP tasks, text analysis, or language modeling guidance below.') }}</p>
<textarea id="nlp-input" placeholder="{{ _('Your NLP request') }}" class="styled-textarea" rows="4"></textarea>
<button id="nlp-btn" class="btn">{{ _('Submit') }}</button>
<div class="response-container" id="nlp-response-container">
<pre id="nlp-response"></pre>
</div>
</div>
</div>
</section>

<!-- AI Content & Fake News Verifier Section -->
<section id="fake-content-verification" class="services">
<h2>{{ _('AI Content & Fake News Verifier') }}</h2>
Expand Down
32 changes: 32 additions & 0 deletions google_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -1319,3 +1319,35 @@ def provide_ia_researcher_assistance(prompt: str) -> str:
except Exception as e:
print(f"Error providing AI researcher assistance with Vertex AI: {e}")
return f"Error: {e}"

def provide_nlp_assistance(prompt: str) -> str:
"""
Provides assistance with Natural Language Processing (NLP) tasks using Vertex AI.
"""
model = GenerativeModel("gemini-1.5-flash")

generation_prompt = f"""
You are an expert Natural Language Processing (NLP) Specialist. Your task is to provide high-level technical guidance, strategy, and problem-solving assistance in the field of NLP.
Your expertise includes:
- Text Processing and Analysis: Advising on tokenization, stemming, lemmatization, part-of-speech tagging, and named entity recognition.
- Language Modeling: Providing insights into N-grams, RNNs, LSTMs, and state-of-the-art Transformer models like BERT, GPT, and T5.
- Sentiment Analysis and Opinion Mining: Guidance on extracting subjective information from text.
- Machine Translation: Advising on neural machine translation architectures and evaluation metrics.
- Question Answering and Chatbots: Providing guidance on building systems that can understand and respond to human language.
- NLP Frameworks and Libraries: Advising on tools like NLTK, spaCy, Hugging Face Transformers, and specialized NLP APIs.

User Request:
---
{prompt}
---

Provide a professional, technical, and detailed response based on the user's request.
"""

try:
response = model.generate_content(generation_prompt)
return response.text.strip()

except Exception as e:
print(f"Error providing NLP assistance with Vertex AI: {e}")
return f"Error: {e}"
Loading