I am try to create an chatbox but i what that by pandas which i pythone libiary but my app is in node and now i want to run phython in node app
this my bash.sh
#!/bin/bash
echo "Current Directory: $(pwd)"
echo "Python Path: $(which python3)"
echo "Environment: $VIRTUAL_ENV"
source "venv/bin/activate"
python "pipeline_script.py"
deactivate
this my index.js
const { exec } = require('child_process');
const path = require('path');
const bashScriptPath = path.join(__dirname, 'run_python_script.sh');
// Enclose the path in double quotes to handle spaces
exec(`bash "${bashScriptPath}"`, (error, stdout, stderr) => {
if (error) {
console.error(`Error: ${error.message}`);
return;
}
if (stderr) {
console.error(`Stderr: ${stderr}`);
return;
}
console.log(`Output: ${stdout}`);
});
this pythone script
from transformers import pipeline
import pandas as pd
# Prepare table + question
data = {"Actors": ["Brad Pitt", "Leonardo Di Caprio", "George Clooney"], "Number of movies": ["87", "53", "69"]}
table = pd.DataFrame.from_dict(data)
question = "how many movies does George Clooney have?"
# Pipeline model
tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq", clean_up_tokenization_spaces=True)
# Get result
print("Python script started.")
print(tqa(table=table, query=question)['cells'][0])
print("Python script finished.")
i want to run phytone script in my node app
New contributor
kanishk soni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.