File size: 7,267 Bytes
4180714 |
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
from groq import Groq
client = Groq(
api_key="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",
)
chat_completion = client.chat.completions.create(
#
# Required parameters
#
messages=[
# Set an optional system message. This sets the behavior of the
# assistant and can be used to provide specific instructions for
# how it should behave throughout the conversation.
{
"role": "system",
"content": '''You are Khanij, an AI assistant for MECL (Mineral Exploration and Consultancy Limited). Based on the user query, determine the appropriate task to perform:
- Print "Heatmap": If the query is related to creating a heatmap.
In the next line, print a Python list with one element: the chemical formula in lowercase mentioned in the query.
- If the query mentions geophysical magnetic data, add 'magnetic_a' to the list.
- If it's related to gravity, add 'bouguer_an' to the list.
- If it's related to elevation, add 'elevation_' to the list.
- Do not print anything else.
- Print "Stat": If the query is related to finding mean, mode, variance, etc., of data.
In the next line, print a Python list with one element: the chemical formula in lowercase mentioned in the query.
- Print "Contour": If the query is related to creating contour maps.
In the next line, print a Python list with one element: the chemical formula in lowercase mentioned in the query.
- If the query mentions geophysical magnetic data, add 'magnetic_a' to the list.
- If it's related to gravity, add 'bouguer_an' to the list.
- If it's related to elevation, add 'elevation_' to the list.
- Do not print anything else.
- Print "Exploration": If the query is about known exploration or excavation sites of the region.
- Print "KrigingInterpolation": If the query is related to Kriging interpolation.
In the next line, print a Python list with one element: the chemical formula in lowercase mentioned in the query.
- If the query mentions geophysical magnetic data, add 'magnetic_a' to the list.
- If it's related to gravity, add 'bouguer_an' to the list.
- If it's related to elevation, add 'elevation_' to the list.
- Do not print anything else.
- Print "IDWInterpolation": If the query is related to IDW (Inverse Distance Weighting) interpolation.
In the next line, print a Python list with one element: the chemical formula in lowercase mentioned in the query.
- If the query mentions geophysical magnetic data, add 'magnetic_a' to the list.
- If it's related to gravity, add 'bouguer_an' to the list.
- If it's related to elevation, add 'elevation_' to the list.
- Do not print anything else.
- Print "SplineInterpolation": If the query is related to spline interpolation.
In the next line, print a Python list with one element: the chemical formula in lowercase mentioned in the query.
- If the query mentions geophysical magnetic data, add 'magnetic_a' to the list.
- If it's related to gravity, add 'bouguer_an' to the list.
- If it's related to elevation, add 'elevation_' to the list.
- Do not print anything else.
- Print "NNInterpolation": If the query is related to nearest neighbor interpolation.
In the next line, print a Python list with one element: the chemical formula in lowercase mentioned in the query.
- If the query mentions geophysical magnetic data, add 'magnetic_a' to the list.
- If it's related to gravity, add 'bouguer_an' to the list.
- If it's related to elevation, add 'elevation_' to the list.
- Do not print anything else.
- Print "Histogram": If the query is related to creating a histogram.
In the next line, print a Python list of chemical formulas mentioned in the query.
- If there are no chemicals mentioned, print a list containing the string 'all'.
- Print a response according to your knowledge: If the query does not relate to any of the specified tasks.
'''
},
# Set a user message for the assistant to respond to.
{
"role": "user",
"content": "Create a heatmap of magnetic data",
}
],
# The language model which will generate the completion.
model="llama3-70b-8192",
#
# Optional parameters
#
# Controls randomness: lowering results in less random completions.
# As the temperature approaches zero, the model will become deterministic
# and repetitive.
temperature=0.5,
# The maximum number of tokens to generate. Requests can use up to
# 2048 tokens shared between prompt and completion.
max_tokens=1024,
# Controls diversity via nucleus sampling: 0.5 means half of all
# likelihood-weighted options are considered.
top_p=1,
# A stop sequence is a predefined or user-specified text string that
# signals an AI to stop generating content, ensuring its responses
# remain focused and concise. Examples include punctuation marks and
# markers like "[end]".
stop=None,
# If set, partial message deltas will be sent.
stream=False,
)
print(chat_completion.choices[0].message.content)
if method==1:
#IDW Interpolation
interpolation_type = "IDW"
grid_z = griddata(points, values, (grid_lat, grid_long), method='cubic')
elif method==2:
#Spline Interpolation:
interpolation_type = "Spline"
tck = bisplrep(points[:, 0], points[:, 1], values, s=0)
#s is the smoothing value and is chosen by trial and error
grid_z = bisplev(grid_lat[:, 0], grid_long[0, :], tck)
elif method==3:
#Kriging interpolation
interpolation_type = "Kriging"
OK = OrdinaryKriging(points[:, 0], points[:, 1], values, variogram_model='linear')
grid_z, _ = OK.execute('grid', grid_lat[0, :], grid_long[:, 0])
elif method==4:
interpolation_type = "Nearest Neighbor"
grid_z = griddata(points, values, (grid_lat, grid_long), method='nearest') |